[Tutorial] ZCMD How to create Goto command
#1

Hi guys, this is my first tutorial, I'll show you how to create a Goto command with ZCMD:
First of all, your includes should be:
Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2> //SSCANF PLUGIN NEED TO BE IN THE STRING "plugins" OF YOUR server.cfg (I know there isn't this string, just write under everything: plugins sscanf)
Now the code:
GOTO:
First of all you need to use the CMD string:
Код:
CMD:goto(playerid, params[])
{
     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "You need to be RCON for use this command"); //This is the line that define if the player is an admin or not, notice: the "!" is same as "if is not" (you can change with your enums);
     return 1;
}
Now I'll show you what this mean:
"CMD:" everyone know this xD;
"goto" it's the Command where we'll use (sorry for my bad english, I'm italian and 13 °>°) with the slash (like "/goto");
"playerid" is the ID who use the command, in this case playerid, is "you";
"params[]" is the param that define our params, like ID, pn, an, ecc."
Now the "new":
Код:
CMD:goto(playerid, params[])
{
     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "You need to be RCON for use this command");
     new ID; //This is the player target (like targetid)
     new pn[MAX_PLAYER_NAME]; //This is the param of ID and it is used for define who was the target
     new an[MAX_PLAYER_NAME];//Same as above but this is used for "me" (playerid), MAX_PLAYER_NAME is the param that get our name
     new str[128]; //This is the string that we'll use in "format"
     return 1;
}
Ah, we are near the finish line!
Now the command!
Код:
CMD:goto(playerid, params[])
{
     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "You need to be RCON for use this command");
     new ID;
     new pn[MAX_PLAYER_NAME]; 
     new an[MAX_PLAYER_NAME];
     new str[128]; 
     if(sscanf(params, "u", ID)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /goto [ID]"); //This is a long line, "sscanf" is the plugin that search the missing params, "params" is the param that define params LOL, "u" is the PARAM that define the MISSING ID, ID is the param for the targetid
     if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: This player is not connected");//Same as !IsPlayerAdmin, but instead of "playerid" we put "ID" because it's the targetid
     GetPlayerName(playerid, an, MAX_PLAYER_NAME);//Define the playerid's param
     GetPlayerName(ID, pn, MAX_PLAYER_NAME);//Define the ID's param
     new Float:x; //Defining float X
     new Float:y; //Same
     new Float:z; //Same
     GetPlayerPos(ID, x, y, z); //This line get the "ID" position
     SetPlayerPos(playerid, x+1, y+1, z); //This line set the "playerid" position from "ID" position, with some changes(x+1, y+1);
     format(str, sizeof(str), "You have been teleported to %s", pn); //Showed before, this is the line that give the message to playerid)
     SendClientMessage(playerid, 0x00FF00AA, str); //This line give the message to playerid
     if(IsPlayerInAnyVehicle(playerid)) //Mhh, let's give you a question, what should this callback do?
     {
          GetPlayerPos(ID, x, y, z);
          SetVehiclePos(playerid, x+1, y+1, z); //And this one? :D
     }
     return 1;
}
IF YOU WANNA TELEPORT INSIDE A VEHICLE THEN:
add under if(IsPlayerInAnyVehicle(ID))
Код:
GetVehiclePos(ID, x, y, z);
PutPlayerInVehicle(playerid, ID, 2);//"2" is the seatid
TESTED: WORKED
Finish, I remember, I'm 13 and I'm italian, my english should not be good!
Reply


Messages In This Thread
ZCMD How to create Goto command - by lorizz - 14.10.2012, 17:11
Re: ZCMD How to create Goto command - by Ghost_Boii - 14.10.2012, 17:15
Re: ZCMD How to create Goto command - by lorizz - 14.10.2012, 17:17
Re: ZCMD How to create Goto command - by MarkoN - 14.10.2012, 22:00
AW: ZCMD How to create Goto command - by Johndaonee - 14.10.2012, 22:04
Re: ZCMD How to create Goto command - by lorizz - 15.10.2012, 14:41
Re: ZCMD How to create Goto command - by Roel - 15.10.2012, 14:41
Re: ZCMD How to create Goto command - by lorizz - 15.10.2012, 16:08
Re: ZCMD How to create Goto command - by nickbouwhuis - 19.10.2012, 15:20
Re: ZCMD How to create Goto command - by Snipa - 21.10.2012, 03:18

Forum Jump:


Users browsing this thread: 5 Guest(s)