SScanf scripting, making a command.
#2

just one and zcmd or?

here's one in ZCMD...


"/get <OtherPlayer>",
pawn Код:
CMD:get(playerid, params[])
{
    new getid; //creates the variable that we're going to be using to represent the param in sscanf
    if(IsPlayerAdmin(playerid)) //checks if they're logged into RCON
    {
         new str[50], getname[MAX_PLAYER_NAME], name[MAX_PLAYER_NAME]; //creates name vars n a string
         new Float:x, Float:y, Float:z; //creates new variables so we can store the positions
         if(sscanf(params, "u", getid)) return SendClientMessage(playerid, COLOR_RED,"USAGE: /get <playerid>"); //checks if the entered param is a playerid/name, if not sends the usage.
         if(IsPlayerAdmin(getid)) return SendClientMessage(playerid, COLOR_RED,"You can't get an admin."); //checks if the other player is an admin. if not, sends an error message.
         GetPlayerName(playerid, name, sizeof(name)); //gets name of the user
         GetPlayerName(getid, getname, sizeof(getname)); //gets name of the other player
         GetPlayerPos(playerid, x,y,z); //gets the players pos
         SetPlayerPos(getid, x+3,y,z); //sets the other players pos
         format(str,sizeof(str), "You have gotten %s", getname); //formats the message so we can send it
         SendClientMessage(playerid, COLOR_RED, str); //sends the message to the player who typed it
         format(str,sizeof(str), "%s has gotten you.", name); //formats the message so we can send it
         SendClientMessage(getid, COLOR_RED, str); //sends the message to the other player
    }
    return 1;
}
Reply


Messages In This Thread
SScanf scripting, making a command. - by rooney12 - 13.12.2011, 19:08
Re: SScanf scripting, making a command. - by [ABK]Antonio - 13.12.2011, 22:04
Re: SScanf scripting, making a command. - by Rob_Maate - 13.12.2011, 23:07
Re: SScanf scripting, making a command. - by rooney12 - 14.12.2011, 12:19
Re: SScanf scripting, making a command. - by Rob_Maate - 14.12.2011, 15:01
Re: SScanf scripting, making a command. - by rooney12 - 14.12.2011, 15:04
Re: SScanf scripting, making a command. - by Rob_Maate - 14.12.2011, 15:14
Re: SScanf scripting, making a command. - by rooney12 - 14.12.2011, 15:15
Re: SScanf scripting, making a command. - by Rob_Maate - 14.12.2011, 15:23
Re: SScanf scripting, making a command. - by rooney12 - 14.12.2011, 15:24

Forum Jump:


Users browsing this thread: 1 Guest(s)