14.10.2012, 17:11
(
Последний раз редактировалось lorizz; 19.10.2012 в 21:06.
)
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:
Now the code:
GOTO:
First of all you need to use the CMD string:
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":
Ah, we are near the finish line!
Now the command!
IF YOU WANNA TELEPORT INSIDE A VEHICLE THEN:
add under if(IsPlayerInAnyVehicle(ID))
TESTED: WORKED
Finish, I remember, I'm 13 and I'm italian, my english should not be good!
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)
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; }
"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; }
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; }
add under if(IsPlayerInAnyVehicle(ID))
Код:
GetVehiclePos(ID, x, y, z); PutPlayerInVehicle(playerid, ID, 2);//"2" is the seatid
Finish, I remember, I'm 13 and I'm italian, my english should not be good!