Register

If you already have an account with us, please use the login panel below to access your account.

Results 1 to 17 of 17
  1. #1
    O.G. Hobo
    #BROOKSIDE NIGGAS

    Taxi Driver
    Alan Brookside's Avatar
    Join Date
    Feb 2016
    Location
    ♡ Australia ♡
    Age
    31
    Posts
    277
    In-Game Name(s)
    .
    Post Thanks / Like

    [Guide] Scripting for beginners (Part 1)



    Tutorial Part 1





    Hello guys. I've decided to make this tutorial since I see that some of you would like to script. I have done it from own experiences but some of the definitions were also adjusted and taken from the internet since I'm not good at explaining things. I'd like to see some more new players interested in scripting and helping the server which is also one of the ways to get the server up and to get it better, with a better playerbase and many new updates, more actively. I hope you guys like it, thanks.




    So basically, SA:MP uses PAWN programming language which is also very similar to the "C" programming language. If you want to start scripting, you have to have the program and to have the basic knowledge. Just to say, becoming a good scripter doesn't take a week, even if you're a superman. It takes a lot of time and SARP's developers have more than 1 year of practicing, even more. I'll go through the steps for the beginners, remember, you can't just build a gamemode from scratch with this tutorial. I'm maybe going to post more if I see some interest here. Basically, I'm going to post easy steps which will help you guys to learn the programming language which is the first step of becoming a good scripter. If you know the ways of PAWN, it's very easy. You know, time matters here.




    What is PAWN? What is PAWNO?

    PAWN is a programming language similar to C language. PAWN isn't used only for SAMP, but also for other programs. It uses CompuPhase Small, which is simple. It's 32 bit extension language. When we know what PAWN is, we came to a question. What is PAWNO? PAWNO is a program (.exe) which was created in order for programming/scripting PAWN. Shortly, PAWN is a programming language, PAWNO is a program on which you can create scripts/filterscripts in PAWN language.




    Step 1 - Downloading needed/recommend files.

    Alright so, I'd recommend you to download a whole server package to make it easier so you can test what you've done yet. You can download Windows server package here and Linux server package here.
    Wait for it to download. After it downloads (which shouldn't take long since it's only 2MB) you need to extract the files somewhere (I'd recommend to desktop). After it's extracted, open the folder and there would be a folder called "pawno". Go into it and there you should see a program called "pawno" as well. Double-click on it and there you go, it's opened.





    Step 2 - Basic knowledge

    Alright so if you want to script yourself and you want to make a gamemode/filterscript, you have to have the basic PAWN programming language knowledge. Alright so, follow my steps and read it carefully from now on. First, when you open "pawno.exe" program, go to the left up corner and browse for a "new file" (blank white paper icon). button. A code of about 100 lines long will pop-up. We will be making a gamemode, not a filterscript. So delete this from the script;
    Code:
    #if defined FILTERSCRIPT
    
    public OnFilterScriptInit()
    {
    	print("\n--------------------------------------");
    	print(" Blank Filterscript by your name here");
    	print("--------------------------------------\n");
    	return 1;
    }
    
    public OnFilterScriptExit()
    {
    	return 1;
    }
    
    #else
    It's not needed to remove, but it gives you a better look-up. You're more lookable over the code. Alright so first we will work on this;
    Code:
    main()
    {
    	print("\n----------------------------------");
    	print(" Blank Gamemode by your name here");
    	print("----------------------------------\n");
    }
    
    #endif
    
    public OnGameModeInit()
    {
    	// Don't use these lines if it's a filterscript
    	SetGameModeText("Blank Script");
    	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    	return 1;
    }
    Alright so this;
    Code:
    {
    	print("\n----------------------------------");
    	print(" Blank Gamemode by your name here");
    	print("----------------------------------\n");
    }
    will actually "print" what you'll write to the console when you'll open the "server.exe". You can name it however you want. I've done it like this (example);
    Code:
    {
    	print("\n----------------------------------");
    	print(" Tutorial Gamemode for Beginners");
    	print("----------------------------------\n");
    }
    Alright. When you've adjusted the SetGameModeText, you can make progress and you can go to the player classes now. Player classes (shortly) are ped moves;
    Code:
    public OnGameModeInit()
    {
    
    	SetGameModeText("T:GM v1.0");
    	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    	return 1;
    }
    You can set the gamemode text to whatever you want. Gamemode text will apear in the SA:MP client such as SARP's (SARP v3.2c - current one). AddPlayerClass is a OnGameModeInit callback, we'll talk about callbacks later. Let's continue with the basic stuff.





    Step 3 - Functions & Callbacks

    Alright as we start, I'll put an example of a basic script which I think everyone will understand;
    Code:
    #include <a_samp>
     
    main() 
    {
    	print("RIP SA:RP 2007-2016");
    	return 1;
    }
    That #include <a_samp> basically loads an .inc file from samp server package folder/pawno/includes/a_samp.inc to the script so you can use it in your script. It's simple. There are many other include files. Many people create their own includes as well so it's easier for them. Alright, so, a function is a chunk of a code which can do something and it can be managed/written to do this thing from somewhere else. So calling;
    Code:
    print("RIP SA:RP 2007-2016");
    calls the function "print" from a_samp.inc. (which is also defined/I will say explained in the programming language) in the a_samp.inc files in your pawno/includes. That's why you also have to #include it. If you wouldn't have, it wouldn't be working, simple. It's a complete logic system. Alright so now you may understand, "print" is a callback defined in a_samp.inc. I won't be that complicated because I guess some of you don't even understand what I've done till now, so I'll go ahead with the basic stuff.




    Step 4 - Classes & Spawnpoints

    Alright, classes. Some of the gamemodes don't have CJ ped move or a custom running style pedmove, they have the normal classes pedmoves, which don't have to be scripted manually. CJ is class 0, for example (it's also skin id 0). Classes can be found in the peds.ide file but you can also use SA:MP debug script to find them easily. You can start debug by going to "C:\Program Files\Rockstar Games\GTA San Andreas\samp_debug.exe". That's the basic root folder of GTA SA installation, by the way. Once you're in samp_debug.exe, you can change classes by using F11 and F12 button on your keyboard. As I've mentioned above;
    Quote Originally Posted by AlanB
    AddPlayerClass is a OnGameModeInit callback, we'll talk about callbacks later. Let's continue with the basic stuff.
    , it's also a callback. You can use;
    Code:
    public OnGameModeInit()
    {
    	
    	SetGameModeText("T:GM v1.0");
    	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    	return 1;
    }
    and players will have CJ's class by playing in the gamemode. You can adjust the classes by looking for them in peds.ide or simply googling them. Let's talk about spawnpoints now. Spawnpoint is a point where player spawns when he/she joins the server (enters the gamemode). You can manage spawnpoints like this (examples);
    Code:
    public OnPlayerRequestClass(playerid, classid // you have to put the class which you've put above in the AddPlayerClass, so when player joins he requests the class automatically and he automatically gets the PlayerClass 0 - if you've set the class 0)
    {
    	SetPlayerPos(playerid, you have to put coordinates of the player's spawn position (ex. sarp has the coords near the skate park));
    	SetPlayerCameraPos(playerid, you have to put the coordinates of the player's camera position here (ex. on sarp your camera is set to be above the skatepark);
    	SetPlayerCameraLookAt(playerid, you have to put coordinates of the player's camera position here - it actually turns the player's screen/look to the coords which you've put there (ex. on sarp you're turned to the newbie spawn building);
    	return 1;
    }
    You can get the coordinates mentioned above by going into debug and typing /save at the position you want to get them. When you type /save, you can go to GTA SA User Files in your Documents folder. Here's an image of how it should look;
    When you'll open the savedpositions.txt there should pop-up something like this;
    If it doesn't, it means you haven't typed /save or there's maybe any other issue (if you have it, PM/VM me or google it).




    Step 5 - Running the Gamemode

    Alright so after you've done that, you should click F5 while being in your pawno.exe. PAWN Compiler will create an .amx file which is used to run the server. Servers can't be ran with .pwn file, because .pwn is used to create a script which you compile to an .amx. Compiler will also give you errors if they are some, but there shouldn't be any. Here's a tutorial how to do this and how to turn the server on;
    1. After you click on the compile button, it will ask you where you want to save the file (.amx)
    2. After it's saved, move it to the gamemodes folder in the SAMP server package.
    3. Open server.cfg and rename the rcon password to whatever you want, gamemode0 to the name of the .amx file you've put in the gamemodes folder and you can adjust the hostname etc.
    4. Open server.exe after you save all those files, it should ask you for the firewall permission unless you have it adjusted already, just click all the boxes and go on.
    5. Go to samp.exe (the samp client) and add 127.0.0.1****** to the favorites list (make sure server.exe is on)
    6. Try to connect to the server, it will print the words you've posted above in this
    Spoiler!
    to the server.exe and to server_log.txt in your server package folder.
    7. When you'd join there should be the class and the camera position that you've set before here
    Spoiler!

    8. I hope it works and you enjoy it. I'll come with a new tutorial soon.


    Step 6 - The End

    Alright guys, I hope you've enjoyed my tutorial and you like it. I'd be posting part 2 soon if I manage to get good opinons and some likes, and if I see that you liked it. I'll be also posting a mapping tutorial soon, when I'll feel to. Alright, so that's the end of my tutorial, again, I hope you've liked it. Thanks for your opinions which you'll be posting (hopefully you will). I hope I've helped some of you guys and you have learned the basics. I'm not going to rush everything in one tutorial. I know it's not the best one, but I've put 2 hours effort into this guys. I'm still not the best in the PAWN, but I can do a lot of things.




    Credits;
    • Alan Brookside (original creator)

    • SAMP Wiki (examples of some codes)




    Last edited by Alan Brookside; 16th February 2016 at 07:43 PM. Reason: Updated!

  2. WTF'd Jacob Price WTF'd this post
  3. #2
    10 Year Veteran 500 Posts500 Posts500 Posts500 Posts Rellex's Avatar
    Join Date
    Nov 2012
    Age
    33
    Posts
    2,325
    In-Game Name(s)
    Dan West
    Post Thanks / Like
    - nvm -

  4. Laughed at Alan Brookside, Kyle Young laughed at this post
    WTF'd Alan Brookside WTF'd this post
  5. #3
    O.G. Hobo
    #BROOKSIDE NIGGAS

    Taxi Driver
    Alan Brookside's Avatar
    Join Date
    Feb 2016
    Location
    ♡ Australia ♡
    Age
    31
    Posts
    277
    In-Game Name(s)
    .
    Post Thanks / Like
    Quote Originally Posted by Rellex View Post
    - nvm -
    What do you mean pal? Is it a good one?
    Finishing my gamemode edit, getting rid of the errors. Will be posted soon, wont dissapoint you guys. I'm going to do what I've promised. I know that everyone has me as a jurke. Just be patient and you'll see the truth.




    Stopped being a kid and stopped shitposting aswell. Apologies for both.

  6. #4
    5 Year Veteran
    Join Date
    Oct 2013
    Posts
    2,809
    In-Game Name(s)
    -
    Post Thanks / Like
    tbh, you just defined how to start off by PAWN, a small similar language to C/C++.

    If you want to be making a good BEGINNER tutorial, start off by the parameters, functions, variables, arithmetic and all of that. You should also make a list of requirements as well. You can also start by saying what is PAWN, what is it made off and how it was developed, just an introduction.

    I wouldn't call myself a beginner, nor a professional but I did see many tutorials and I can say that this one isn't bad. You directly started with giving examples for the functions and not mentioning the use of the function, the use of the #include, how was it made and all that.

    To make a tutorial, you should be a professional or probably more to answer any questions that you may be asked.

  7. Thanks Alan Brookside thanked for this post
  8. #5
    O.G. Hobo
    #BROOKSIDE NIGGAS

    Taxi Driver
    Alan Brookside's Avatar
    Join Date
    Feb 2016
    Location
    ♡ Australia ♡
    Age
    31
    Posts
    277
    In-Game Name(s)
    .
    Post Thanks / Like
    Quote Originally Posted by Jizzy Black View Post
    tbh, you just defined how to start off by PAWN, a small similar language to C/C++.

    If you want to be making a good BEGINNER tutorial, start off by the parameters, functions, variables, arithmetic and all of that. You should also make a list of requirements as well. You can also start by saying what is PAWN, what is it made off and how it was developed, just an introduction.

    I wouldn't call myself a beginner, nor a professional but I did see many tutorials and I can say that this one isn't bad. You directly started with giving examples for the functions and not mentioning the use of the function, the use of the #include, how was it made and all that.

    To make a tutorial, you should be a professional or probably more to answer any questions that you may be asked.
    Thanks for your response pal, I appreciate it. I will take those into the Part 2 tutorial, and I will hopefully make it better. This is my first tutorial I've ever made tbh, thanks for being honest pal. Just tryna help out ya know :-)

    Or I'll just edit the main post in few hours, tired af.
    Finishing my gamemode edit, getting rid of the errors. Will be posted soon, wont dissapoint you guys. I'm going to do what I've promised. I know that everyone has me as a jurke. Just be patient and you'll see the truth.




    Stopped being a kid and stopped shitposting aswell. Apologies for both.

  9. #6
    Old-School Veteran 500 Posts500 Posts500 Posts500 Posts500 Posts Michael's Avatar
    Join Date
    Sep 2011
    Location
    London
    Posts
    4,350
    Post Thanks / Like

  10. Thanks Jason™ thanked for this post
    Laughed at Shawn Jarvis. laughed at this post
    Likes Rellex liked this post
  11. #7
    10 Year Veteran 500 Posts500 Posts500 Posts500 Posts Rellex's Avatar
    Join Date
    Nov 2012
    Age
    33
    Posts
    2,325
    In-Game Name(s)
    Dan West
    Post Thanks / Like
    Unless you plan on teaching absolutely everything, I highly doubt this will be useful.

  12. Thanks Kyle Young thanked for this post
  13. #8
    O.G. Hobo
    #BROOKSIDE NIGGAS

    Taxi Driver
    Alan Brookside's Avatar
    Join Date
    Feb 2016
    Location
    ♡ Australia ♡
    Age
    31
    Posts
    277
    In-Game Name(s)
    .
    Post Thanks / Like
    Quote Originally Posted by Michael View Post
    I've already mentioned that I've typed it myself but I've also took some examples from other sites. I'm going to list credits if you want, lol.

    Quote Originally Posted by Rellex View Post
    Unless you plan on teaching absolutely everything, I highly doubt this will be useful.
    I will, but not in one tutorial. Probably in like 10 tutorial parts. I'm not that good as you are I guess, and I'll still be learning and posting here. Thanks for all the suggestions and I'll be editing this one very soon.
    Last edited by Alan Brookside; 16th February 2016 at 03:38 PM.
    Finishing my gamemode edit, getting rid of the errors. Will be posted soon, wont dissapoint you guys. I'm going to do what I've promised. I know that everyone has me as a jurke. Just be patient and you'll see the truth.




    Stopped being a kid and stopped shitposting aswell. Apologies for both.

  14. #9
    Old-School Veteran 500 Posts500 Posts500 Posts500 Posts500 Posts Michael's Avatar
    Join Date
    Sep 2011
    Location
    London
    Posts
    4,350
    Post Thanks / Like
    Quote Originally Posted by AlanB View Post
    I've already mentioned that I've typed it myself but I've also took some examples from other sites. I'm going to list credits if you want, lol.
    You should always list credits.

  15. #10
    O.G. Hobo
    #BROOKSIDE NIGGAS

    Taxi Driver
    Alan Brookside's Avatar
    Join Date
    Feb 2016
    Location
    ♡ Australia ♡
    Age
    31
    Posts
    277
    In-Game Name(s)
    .
    Post Thanks / Like
    Quote Originally Posted by Michael View Post
    You should always list credits.
    Alright, thanks for the reminder mate.
    Finishing my gamemode edit, getting rid of the errors. Will be posted soon, wont dissapoint you guys. I'm going to do what I've promised. I know that everyone has me as a jurke. Just be patient and you'll see the truth.




    Stopped being a kid and stopped shitposting aswell. Apologies for both.

  16. #11
    Retired Developer 500 Posts500 Posts500 Posts DwayneD's Avatar
    Join Date
    Sep 2015
    Age
    39
    Posts
    1,662
    In-Game Name(s)
    Dwayne_Dutch
    Post Thanks / Like
    I have to agree with Jizzy in the fact that you just fly by the essentials and aren't even considering this to be "beginner-friendly". You don't explain what the thing's actually doing(example; AddPlayerClass), just how to add it. Not really a method someone new to the language should be introduced to(in my honest opinion it seems like you are just giving code throughout much of the tutorial). Another example in AddPlayerClass are the x, y, z coordinates. Someone new to this type of system(especially PAWN/C languages as well) may not know how to use those(or how to get them from the game). All in all, this isn't a very good tutorial for a person who has never seen C nor PAWN, try to do some further editing to improve it's friendliness to beginners.
    Last edited by DwayneD; 16th February 2016 at 04:20 PM.
    resigned

    What I've done:
    Spoiler!

  17. Thanks Alan Brookside thanked for this post
  18. #12
    O.G. Hobo
    #BROOKSIDE NIGGAS

    Taxi Driver
    Alan Brookside's Avatar
    Join Date
    Feb 2016
    Location
    ♡ Australia ♡
    Age
    31
    Posts
    277
    In-Game Name(s)
    .
    Post Thanks / Like
    Quote Originally Posted by DwayneD View Post
    I have to agrre with Jizzy in the fact that you just fly by the essentials and aren't even considering this to be "beginner-friendly". You don't explain what the thing's actually doing(example; AddPlayerClass), just how to add it.
    (You don't even explain what the coordinates are, how would a beginner be expected to know this?)

    All in all, this isn't a very good tutorial for a person who has never seen C nor PAWN.
    I agree with it too. Please excuse me, it's my first tutorial. I'll be improving it mate. Thanks for your honest reply.
    Finishing my gamemode edit, getting rid of the errors. Will be posted soon, wont dissapoint you guys. I'm going to do what I've promised. I know that everyone has me as a jurke. Just be patient and you'll see the truth.




    Stopped being a kid and stopped shitposting aswell. Apologies for both.

  19. #13
    10 Year Veteran 500 Posts500 Posts500 Posts500 Posts Rellex's Avatar
    Join Date
    Nov 2012
    Age
    33
    Posts
    2,325
    In-Game Name(s)
    Dan West
    Post Thanks / Like
    Quote Originally Posted by AlanB View Post
    I will, but not in one tutorial. Probably in like 10 tutorial parts. I'm not that good as you are I guess, and I'll still be learning and posting here. Thanks for all the suggestions and I'll be editing this one very soon.
    You should get lead dev if you can do a whole language in 10 tutorials

  20. Laughed at $kylar, J laughed at this post
    WTF'd J WTF'd this post
  21. #14
    8 Year Veteran Tommy Corleone's Avatar
    Join Date
    Mar 2012
    Location
    Netherlands
    Posts
    1,761
    In-Game Name(s)
    Tawmi Cawrleoni
    Post Thanks / Like
    I tried but all I managed to do is spawn with a dildo make it more detailed
    Safa leen me geld

  22. #15
    O.G. Hobo
    #BROOKSIDE NIGGAS

    Taxi Driver
    Alan Brookside's Avatar
    Join Date
    Feb 2016
    Location
    ♡ Australia ♡
    Age
    31
    Posts
    277
    In-Game Name(s)
    .
    Post Thanks / Like
    Quote Originally Posted by Tommy Corleone View Post
    I tried but all I managed to do is spawn with a dildo make it more detailed
    I've also posted that I'm going to, thanks for your reply.

    troll

    Quote Originally Posted by Rellex View Post
    You should get lead dev if you can do a whole language in 10 tutorials
    I didn't mean exactly 10, I just said I'll do at least 10 tuts or even more.
    Finishing my gamemode edit, getting rid of the errors. Will be posted soon, wont dissapoint you guys. I'm going to do what I've promised. I know that everyone has me as a jurke. Just be patient and you'll see the truth.




    Stopped being a kid and stopped shitposting aswell. Apologies for both.

  23. #16
    5 Year Veteran 500 Posts500 Posts500 Posts500 Posts Kiyomi's Avatar
    Join Date
    Apr 2013
    Posts
    2,052
    In-Game Name(s)
    Vee
    Post Thanks / Like
    Your saying that this is tutorial for beginners yet you haven't explained anything properly at all, You're using words like
    Alright so this;
    Alright, we will go on;

    and when you do all you doing is skipping the scripting part and showing a sample of what you did but never explained why and never told your audience on what does every number represent, what the function does, how you could improve the function and etc.

    explain in details between every step, let your audience/student know what you're talking about otherwise, no offense but this is just crap and a copy & paste from my Point of View.(yeh, quit the "I've typed it myself but I've also took some examples from other sites." bullshit, we all know that story by now.)


    ^^ Click it



    Spoiler!


  24. Thanks Alan Brookside thanked for this post
  25. #17
    O.G. Hobo
    #BROOKSIDE NIGGAS

    Taxi Driver
    Alan Brookside's Avatar
    Join Date
    Feb 2016
    Location
    ♡ Australia ♡
    Age
    31
    Posts
    277
    In-Game Name(s)
    .
    Post Thanks / Like
    Quote Originally Posted by Kiyomi™ View Post
    Your saying that this is tutorial for beginners yet you haven't explained anything properly at all, You're using words like
    Alright so this;
    Alright, we will go on;

    and when you do all you doing is skipping the scripting part and showing a sample of what you did but never explained why and never told your audience on what does every number represent, what the function does, how you could improve the function and etc.

    explain in details between every step, let your audience/student know what you're talking about otherwise, no offense but this is just crap and a copy & paste from my Point of View.(yeh, quit the "I've typed it myself but I've also took some examples from other sites." bullshit, we all know that story by now.)
    Alright, 7th time, I'm editing it right now. Thanks!

    EDIT: Updated it a bit, please tell me if you see any other issues I should update.
    Last edited by Alan Brookside; 16th February 2016 at 07:44 PM.
    Finishing my gamemode edit, getting rid of the errors. Will be posted soon, wont dissapoint you guys. I'm going to do what I've promised. I know that everyone has me as a jurke. Just be patient and you'll see the truth.




    Stopped being a kid and stopped shitposting aswell. Apologies for both.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Click to connect to Discord (San Andreas Roleplay)Click to go to the official San Andreas Multiplayer websiteDownload Teamspeak