11.09.2012, 16:52
(
Последний раз редактировалось NL-Sultan; 30.05.2013 в 15:42.
)
First Word
What's up everyone, I've been scripting for about four days right now and I did already learn some stuff. I'd like to share my knowledge with the other newbies who are trying to start with PAWN but can't do it or just want a tutorial. I do already know the basics of ZCMD and scripting some simple things, I'll try to explain everything as clear as possible. Reply on this thread if you've got any questions.NOTES:
A lot of people miss-understand some things, so read this first:
In pawn playerid means the player himself, I had problem with this, I always thought I had to fill in a ID!
// is used to make notes inside the script, you can see more of this below for example.
You start and end your script with a { and }, and always end lines with a ;.
The most common errors while compiling is failing to end your script, or forgetting to end a line or spelled something wrong.
Press TAB to make some space, this is needed, you'll see it in the examples below aswell, TAB is the same as tabbing 4 times space.
ZCMD? What is that?
You can use ZCMD for making scripts such as commands, when you type a command there will happen something. What will happen is up to you, this can be everything, it can play a song, you can make it heal the player, you can make it to set the hp of the player, anything you want! Now, lets stop talking and lets go to the real part.Scripting!
Before starting with ZCMD, you need to download the ZCMD include and put it into your gamemode.The ZCMD file is just a small text file, nothing big.
Download it here: https://sampforum.blast.hk/showthread.php?tid=91354
Put it in [your gamemode map] > [pawno] > [include]
Now put on the top of your script:
pawn Код:
#include <zcmd>
When using ZCMD, you always start with CMD:COMMANDNAME, lets say, we want to make a command that will set your HP to 100 called refill hp. So lets say, when you type /refillhp it restores your hp. Lets script that!
pawn Код:
CMD:refillhp(playerid, params[])
After typing that, you got to show the computer that you're going to 'start', so place a { under the CMD.
At the end of your script you always but a }, so you do at the start!
pawn Код:
CMD:refillhp (playerid, params[])
{ // The { means the start, when you end the script you do the same but with a } at the end.
pawn Код:
CMD:refillhp (playerid, params[])
{
if(PlayerInfo[playerid]) return SendClientMessage, COLOR_GREY ''You are not a player.''); //You always end with a ;, but be sure that you wont end the cmd itself with a ;
Now, if everything is alright, we script that his hp gets setted, lets go.
pawn Код:
CMD:refillhp (playerid, params[])
{
if(PlayerInfo[playerid]) return SendClientMessage, COLOR_GREY ''You are not a player.''); //You always end with a ;, but be sure that you wont end the cmd itself with a ;
SetPlayerHealth(playerid, 100); //Use 'SetPlayerHealth', it's your choice if it will give 100 hp, more, or less.
Lets do that.
pawn Код:
CMD:refillhp (playerid, params[])
{
if(PlayerInfo[playerid]) return SendClientMessage, COLOR_GREY ''You are not a player.''); //You always end with a ;, but be sure that you wont end the cmd itself with a ;
SetPlayerHealth(playerid, 100); //Use 'SetPlayerHealth', it's your choice if it will give 100 hp, more, or less.
return 1;
}
//This spaces in front of the lines are needed, use the TAB button to do it.