20.08.2012, 20:36
(
Последний раз редактировалось gtakillerIV; 22.08.2012 в 18:44.
)
Hey guys today I will tell you how to make a /afk and a /back command..Ok so lets start shall we?
What will I need for this tutorial?
You will only need ZCMD
What Is ZCMD?
ZCMD is a fast and simple command processor made by Zeex
Where can I download ZCMD?
You can get it here http://forum.sa-mp.com/showthread.ph...highlight=zcmd
How can I install ZCMD?
Copy zcmd.inc and paste it into your pawno\includes folder
Remember to add at the top of your game mode :-
And define this color :-
(Add this below your #includes)
Remember that ZCMD doesn't work inside a callback at all
Here is an example of a callback :-
Remember that using return 0; Wont make the command work so use return 1; .
Now we are ready for the code (I hope I do good here I am new to making tutorials here).
Scroll down to the bottom of your game mode and type this in :-
The CMD format is for Zcmd it can also be COMMAND it doesn't matter at all if you use CMD, or COMMAND, command, and instead of "params" you can just add an "o" not the number zero. Remember that pawno is case sensitive for example if I type in :-
It wont work at all.
.................................................. ........
Now lets get into the script.
Let me explain this :-
Here were are defining the "name" to MAX_PLAYER_NAME what this basicly does is that it makes pawno understand that "name" is someones ingame name.
Here we are creating a new string with the size of 128. Remeber in a string you can add anything into it for example :- Characters, numbers, symbols...etc. You can name it what ever you like for example :- apple[128].
This part here gets the playerid's name (Which in our case it is your player's name) and assigns it to "name" and its size is MAX_PLAYER_NAME.
Now lets format our string.
This basicly formats our string to make it say what we want it to. Remember that this wont send the message to anyone, this is when SendClientMessageToAll comes in handy. Remember that %s is a specifier
Here we are sending to everyone that is connected to the server our string that we just formated.
Now for the last step :-
This part makes the player not controllable what I mean by that is that you can't move AT ALL even the camera.
Now lets add return 1; and the right sided curly bracket.
Here is the full command :-
Now for the /back command.
Again this format is for Zcmd and it doesnt matter if you choose CMD or COMMAND.
Again here we are making a new "name" and a new string with the size of [128].
Here we are getting the playerid's name (In our case it is us) and assigns it to "name" and we set its size to MAX_PLAYER_NAME.
Now lets format our string.
Now we just formated our string now lets make our string get sent to all players in our server.
Here we will send our string to all of the player with the color of green and the text is our "string".
Now lets make the player moveable again shall we?
Here we are making the player moveable again. remember 1 = True, 0 = False.
Now lets add the return 1; and the right sided curvey bracket.
Full command :-
Credits :-
Zex for his awesome Zcmd, thanks alot.
Thanks guys I hope my tutorial is good.
Please tell me if I should add anything or if there is a mistake thanks
What will I need for this tutorial?
You will only need ZCMD
What Is ZCMD?
ZCMD is a fast and simple command processor made by Zeex
Where can I download ZCMD?
You can get it here http://forum.sa-mp.com/showthread.ph...highlight=zcmd
How can I install ZCMD?
Copy zcmd.inc and paste it into your pawno\includes folder
Remember to add at the top of your game mode :-
Код:
#include <zcmd>
(Add this below your #includes)
Код:
#define Green 0x33AA33AA
Here is an example of a callback :-
Код:
public OnGameModeInit()
Now we are ready for the code (I hope I do good here I am new to making tutorials here).
Scroll down to the bottom of your game mode and type this in :-
Код:
CMD:afk(playerid, params[]) {
Код:
sendclientmessage(playerid, yellow, "lol");
.................................................. ........
Now lets get into the script.
Код:
new name[MAX_PLAYER_NAME], string[128];
Код:
new name[MAX_PLAYER_NAME]
Код:
string[128]
Код:
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
Now lets format our string.
Код:
format(string, sizeof(string), "%s is now afk", name);
Код:
SendClientMessageToAll(Green, string);
Now for the last step :-
Код:
TogglePlayerControllable(playerid, 0);
Now lets add return 1; and the right sided curly bracket.
Код:
return 1; }
Код:
CMD:afk(playerid, params[]) { new name[MAX_PLAYER_NAME], string[128]; //Here we area creating a new "name" and a new "string" with the size of 128. What the size basicly means is the amount of words..symbols..etc it can carry. GetPlayerName(playerid, name, MAX_PLAYER_NAME); //Here we are getting the name of the "playerid" which is us, and we are assigning/defining it to "name" with the size of max player name. format(string, sizeof(string), "%s is now afk", name); //Now here we are formating our string that we just made. What I mean by that is that we are adding our text in the string, and letting pawno add the name of our playerid which again is us..if you look at this part "%s is now afk", name %s means a string and if you test this ingame I think you will get it, after our text there is ",name" at this part we are telling pawno that the %s is the value of "name" that we just defined earlier. SendClientMessageToAll(Green, string); //Now here we are sending our string to everyone in the server. TogglePlayerControllable(playerid, 0); //Here we are making the player not moveable what I mean by that is that he can't move at all, he can't even move the camera. return 1; // Here we are making the our code get returned to the player what I mean by that is that it will let the code work. If you choose return 0 it wont return anything, ingame you will get the UNKOWN SERVER COMMAND error }
Код:
CMD:back(playerid, params[]) {
Код:
new name[MAX_PLAYER_NAME], string[128];
Код:
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
Now lets format our string.
Код:
format(string, sizeof(string), "%s is now back from afk", name);
Код:
SendClientMessageToAll(Green, string);
Now lets make the player moveable again shall we?
Код:
TogglePlayerControllable(playerid, 1);
Now lets add the return 1; and the right sided curvey bracket.
Код:
return 1; }
Код:
CMD:back(playerid, params[]) { new name[MAX_PLAYER_NAME], string[128]; //Again here we are creating a new "name" and a new "string" with the size of 128. GetPlayerName(playerid, name, MAX_PLAYER_NAME); //Here we are getting the playerid's name which means us the guy that typed in the command..So now we are getting the name of the player that typed in the command and assigning it to "name" with the size of max player name. format(string, sizeof(string), "%s is now back from afk", name); //Now here we are formating our string. SendClientMessageToAll(Green, string); //Here we are sending our string to everyone in the server. TogglePlayerControllable(playerid, 1); //At this part we are making the player moveable again. return 1; //Here we are making the code get returned to the player so it works. }
Zex for his awesome Zcmd, thanks alot.
Thanks guys I hope my tutorial is good.
Please tell me if I should add anything or if there is a mistake thanks