SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 17/05/2020, 11:13 AM   #1
LaKhWaN
Little Clucker
 
Join Date: Apr 2020
Posts: 23
Reputation: 9
Default [Help] Beginner Help

Hello there,
I am new at this forums and on scripting too. So about my experience, I know python basics ONLY. But I want to learn pawno and for now, I know basics like how to create /heal /tpto etc. I watched almost every video on youtube about tuts. But I want to learn advance. attach some links or help me. Just think I am totally nub, idk anything
LaKhWaN is offline   Reply With Quote
Old 17/05/2020, 12:23 PM   #2
NoteND
Huge Clucker
 
Join Date: May 2016
Posts: 261
Reputation: 5
Default Re: [Help] Beginner Help

Well for start (assuming you know how to include includes) I want you to download and include these 2 includes / plugins in your gamemode..

sscanf: https://forum.sa-mp.com/showthread.php?t=570927
Pawn.CMD: https://forum.sa-mp.com/showthread.php?t=608474

With these 2 plugins you can create commands.. Here's example

Code:
CMD:heal(playerid, params[]) // In this case you will have to type /heal in game for this command to work.
{
	new string[128], pID, Float:Health; //We will create a new variable "pID" which will define which player id we want to heal, float variable (tag) to store player's health in and name it "Health" and "string" to format it later and sent formatted messages.
	if(sscanf(params, "d", pID)) return SendClientMessage(playerid, -1, "USAGE: /heal (playerid)"); //Using "sscanf" we can check if player type "/heal" in chat, this message will pop out, letting him know he has to use /heal (playerid).
	if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, -1, "That player is not connected."); //Using "!IsPlayerConnected" we check if player (playerid) we are trying to heal is even connected, if not, this message will be sent and command will not be executed.
	GetPlayerHealth(pID, Health); //Thats the function to get player's health	
	if(Health == 100) return SendClientMessage(playerid, -1, "Player is already full Health."); //With this, we check if player's health is 100, that means he doesnt need to be healed and.
	SetPlayerHealth(pID, 100.0);
	
	format(string, sizeof(string), "You have healed %s (%d).", PlayerName(pID), pID); //Formatting the message, you can checke the specifiers we use in this case on sscanf website I linked above.
	SendClientMessage(playerid, -1, string); //Sending message
	
	format(string, sizeof(string), "You have been healed by %s.", PlayerName(playerid)); //Formatting the message, you can checke the specifiers we use in this case on sscanf website I linked above.
	SendClientMessage(pID, -1, string); //Sending message
	return 1;
}

PlayerName(playerid)
{
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	return name;
}
Might be complicated, but try to read the command through, and then go through "Pawn.CMD" and "sscanf" websites I linked above, and you will being to understand how it works.

Behind "//" (comment) I specified what each line does.
NoteND is offline   Reply With Quote
Old 17/05/2020, 01:11 PM   #3
Kwarde
High-roller
 
Kwarde's Avatar
 
Join Date: Nov 2009
Location: The Netherlands
Posts: 2,856
Reputation: 1693
Default Re: [Help] Beginner Help

First of all, the language is Pawn and not pawno (pawno is an editor, which uses pawncc as compiler).

You may want to start with this one: https://github.com/compuphase/pawn/b...uage_Guide.pdf
Make sure you read this one aswell: https://wiki.sa-mp.com/wiki/Scripting_Basics

These tutorials I find pretty important aswell (especially the arrays one):
https://forum.sa-mp.com/showthread.php?p=876854
https://forum.sa-mp.com/showthread.php?t=318212

Apart from that you should just download scripts on the forums here and look into them and try to understand what it does. Then start creating your own stuff. Just play around with coding a bit and see what it does during runtime (tip: Use alot of debugging messages -It tells you exactly what is happening -or not if it does not pop up).

Also you might wanna check out the YSI library (look it up).
__________________
When the opportunity presents itself to flip-a da table, uh, you flip-a da table.

Discord: Kwarde#8009
Kwarde is offline   Reply With Quote
Old 17/05/2020, 02:36 PM   #4
LaKhWaN
Little Clucker
 
Join Date: Apr 2020
Posts: 23
Reputation: 9
Default Re: [Help] Beginner Help

Quote:
Originally Posted by NoteND View Post
Well for start (assuming you know how to include includes) I want you to download and include these 2 includes / plugins in your gamemode..

sscanf: https://forum.sa-mp.com/showthread.php?t=570927
Pawn.CMD: https://forum.sa-mp.com/showthread.php?t=608474

With these 2 plugins you can create commands.. Here's example

Code:
CMD:heal(playerid, params[]) // In this case you will have to type /heal in game for this command to work.
{
	new string[128], pID, Float:Health; //We will create a new variable "pID" which will define which player id we want to heal, float variable (tag) to store player's health in and name it "Health" and "string" to format it later and sent formatted messages.
	if(sscanf(params, "d", pID)) return SendClientMessage(playerid, -1, "USAGE: /heal (playerid)"); //Using "sscanf" we can check if player type "/heal" in chat, this message will pop out, letting him know he has to use /heal (playerid).
	if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, -1, "That player is not connected."); //Using "!IsPlayerConnected" we check if player (playerid) we are trying to heal is even connected, if not, this message will be sent and command will not be executed.
	GetPlayerHealth(pID, Health); //Thats the function to get player's health	
	if(Health == 100) return SendClientMessage(playerid, -1, "Player is already full Health."); //With this, we check if player's health is 100, that means he doesnt need to be healed and.
	SetPlayerHealth(pID, 100.0);
	
	format(string, sizeof(string), "You have healed %s (%d).", PlayerName(pID), pID); //Formatting the message, you can checke the specifiers we use in this case on sscanf website I linked above.
	SendClientMessage(playerid, -1, string); //Sending message
	
	format(string, sizeof(string), "You have been healed by %s.", PlayerName(playerid)); //Formatting the message, you can checke the specifiers we use in this case on sscanf website I linked above.
	SendClientMessage(pID, -1, string); //Sending message
	return 1;
}

PlayerName(playerid)
{
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	return name;
}
Might be complicated, but try to read the command through, and then go through "Pawn.CMD" and "sscanf" websites I linked above, and you will being to understand how it works.

Behind "//" (comment) I specified what each line does.
Thanks for the help, but can you tell me what did %s %d do? I mean what does the line mean (format,sizeof string) what is sizeof string string? Can you explain that briefly?
Because i can create this command, but not like this and i wanna know like this.
Thanks.
LaKhWaN is offline   Reply With Quote
Old 17/05/2020, 02:38 PM   #5
LaKhWaN
Little Clucker
 
Join Date: Apr 2020
Posts: 23
Reputation: 9
Default Re: [Help] Beginner Help

Quote:
Originally Posted by Kwarde View Post
First of all, the language is Pawn and not pawno (pawno is an editor, which uses pawncc as compiler).

You may want to start with this one: https://github.com/compuphase/pawn/b...uage_Guide.pdf
Make sure you read this one aswell: https://wiki.sa-mp.com/wiki/Scripting_Basics

These tutorials I find pretty important aswell (especially the arrays one):
https://forum.sa-mp.com/showthread.php?p=876854
https://forum.sa-mp.com/showthread.php?t=318212

Apart from that you should just download scripts on the forums here and look into them and try to understand what it does. Then start creating your own stuff. Just play around with coding a bit and see what it does during runtime (tip: Use alot of debugging messages -It tells you exactly what is happening -or not if it does not pop up).

Also you might wanna check out the YSI library (look it up).
Thanks lemme look it..
LaKhWaN is offline   Reply With Quote
Old 17/05/2020, 03:33 PM   #6
Kwarde
High-roller
 
Kwarde's Avatar
 
Join Date: Nov 2009
Location: The Netherlands
Posts: 2,856
Reputation: 1693
Default Re: [Help] Beginner Help

Quote:
Originally Posted by LaKhWaN View Post
Thanks for the help, but can you tell me what did %s %d do? I mean what does the line mean (format,sizeof string) what is sizeof string string? Can you explain that briefly?
Because i can create this command, but not like this and i wanna know like this.
Thanks.
%s and %d are format specifiers. s for strings, d for decimals, i for integers, f for floats etcetera.
More information on format() and the format specifiers here: https://wiki.sa-mp.com/wiki/Format

Sometimes you may need to format a string (array) with some information that does not have a static value (eg. a player's name). The script itself once compiled does not change. Therefor you'll need functions like format() to manipulate an array during runtime.

If you have questions about a function, navigate to https://wiki.sa-mp.com/wiki/FUNCTION_NAME -Note that it is case sensitive (the function name) except for the first characters.
The wiki describes allmost all functions, what they do, and how they work (parameters usage and an example).
__________________
When the opportunity presents itself to flip-a da table, uh, you flip-a da table.

Discord: Kwarde#8009
Kwarde is offline   Reply With Quote
Old 17/05/2020, 03:56 PM   #7
LaKhWaN
Little Clucker
 
Join Date: Apr 2020
Posts: 23
Reputation: 9
Default Re: [Help] Beginner Help

Quote:
Originally Posted by Kwarde View Post
First of all, the language is Pawn and not pawno (pawno is an editor, which uses pawncc as compiler).

You may want to start with this one: https://github.com/compuphase/pawn/b...uage_Guide.pdf
Make sure you read this one aswell: https://wiki.sa-mp.com/wiki/Scripting_Basics

These tutorials I find pretty important aswell (especially the arrays one):
https://forum.sa-mp.com/showthread.php?p=876854
https://forum.sa-mp.com/showthread.php?t=318212

Apart from that you should just download scripts on the forums here and look into them and try to understand what it does. Then start creating your own stuff. Just play around with coding a bit and see what it does during runtime (tip: Use alot of debugging messages -It tells you exactly what is happening -or not if it does not pop up).

Also you might wanna check out the YSI library (look it up).
Thanks, I read all the threads, excepts that big pdf... If its really important tell me I will read it too..
Also if any video available tell me. I really want to learn pawn language.
LaKhWaN is offline   Reply With Quote
Old 17/05/2020, 04:20 PM   #8
Kwarde
High-roller
 
Kwarde's Avatar
 
Join Date: Nov 2009
Location: The Netherlands
Posts: 2,856
Reputation: 1693
Default Re: [Help] Beginner Help

Quote:
Originally Posted by LaKhWaN View Post
I read all the threads, excepts that big pdf...
I really want to learn pawn language.
That big pdf is the official pawn language guide from the creators of the language. If you really want to learn pawn, that is the perfect document to start with.
__________________
When the opportunity presents itself to flip-a da table, uh, you flip-a da table.

Discord: Kwarde#8009
Kwarde is offline   Reply With Quote
Old 18/05/2020, 04:10 AM   #9
LaKhWaN
Little Clucker
 
Join Date: Apr 2020
Posts: 23
Reputation: 9
Default Re: [Help] Beginner Help

Others? Please help me I literally want to learn the language pawn. Please I want help from everyone.
LaKhWaN is offline   Reply With Quote
Old 18/05/2020, 04:39 AM   #10
StevenLV
Big Clucker
 
StevenLV's Avatar
 
Join Date: Apr 2017
Location: Pakistan
Posts: 144
Reputation: 11
Default Re: [Help] Beginner Help

Not everyone can reply to this thread bro, and why do you want to ask from EVERYONE xd ?
All are going to give you the same exact answer. The thing is, logic is more important than the syntax, you can learn the syntax but you need logic.
I will say, first read the pdf. I know its pain ... to read a pdf .. for me tbh but yea do it. Then see the Tutorials on the forum here. And download different gamemodes and then Check how they are scripted, and learn the logic of things how they work.
Everyone will tell u to do this..
__________________
Quote:
Eternal Life Roleplay - An upcoming unique RP server based in Palomino Creek
https://discord.gg/JWzE78r
Quote:
Originally Posted by !damo!spiderman View Post
You're pathetic. Stand for something that's going to help the world rather than fill it with more hate. Give someone a hug, tell someone you care... Do something, do anything but do it with love not hate.
StevenLV is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to fix that please help me i'm beginner merrissa143 Scripting Help 2 18/02/2020 08:31 AM
Help me! Im beginner! Boshishere12 Scripting Help 5 06/04/2014 01:39 PM
help for a beginner vivid6 Help Archive 2 30/07/2011 02:53 AM
What to do as a beginner? Everybody Help Archive 12 03/10/2010 03:07 PM
Help please,im beginner :) kingdom99 Help Archive 5 26/05/2010 06:29 AM


All times are GMT. The time now is 10:50 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.