How to create command /san
#1

How can I create I command call /san to sanction a player. What i'll do it's that it will send a player to the coordinates X, Y, Z. Help?

EDIT: And I want it to spawn back in X, Y, Z, after 1 minute...
Reply
#2

pawn Код:
if(!strcmp(cmd,"/san",true))
{
new tmp[256];
tmp = strtok(cmdtext,idx);
if(!strlen(tmp) || !IsNumeric(tmp)) return scm(playerid,-1,"/san <id>");
new id = strval(tmp);
if(!IsPlayerConnected(id)) return scm(playerid,-1,"This Players Isn't Connected !");
SetPlayerPos(id,x,y,z);// change yourself
return 1;
}
Reply
#3

Quote:
Originally Posted by mineralo
Посмотреть сообщение
pawn Код:
if(!strcmp(cmd,"/san",true))
{
new tmp[256];
tmp = strtok(cmdtext,idx);
if(!strlen(tmp) || !IsNumeric(tmp)) return scm(playerid,-1,"/san <id>");
new id = strval(tmp);
if(!IsPlayerConnected(id)) return scm(playerid,-1,"This Players Isn't Connected !");
SetPlayerPos(id,x,y,z);// change yourself
return 1;
}
I use ZCMD Help me please. I don't know how to pass it to a ZCMD command.
Reply
#4

pawn Код:
CMD:san(playerid, params[])
{
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, -1, "USAGE: /san [name/id]");
    SetPlayerPos(id, X, Y, Z);
    //SetPlayerFacingAngle(playerid, Angle); //Optional, but replace 'Angle' with your own float
    return 1;
}
Replace X, Y and Z with the appropriate floats.
Reply
#5

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
pawn Код:
CMD:san(playerid, params[])
{
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, -1, "USAGE: /san [name/id]");
    SetPlayerPos(id, X, Y, Z);
    //SetPlayerFacingAngle(playerid, Angle); //Optional, but replace 'Angle' with your own float
    return 1;
}
Replace X, Y and Z with the appropriate floats.
SSCANF again 7_7. has i said no ssanf men
Reply
#6

SSCANF is the easiest and fastest option... none of that strtok crap. I'd recommend switching to it ASAP...
Reply
#7

Can any one edit the the command please. Thank you
Reply
#8

Quote:
Originally Posted by Lauder
Посмотреть сообщение
SSCANF again 7_7. has i said no ssanf men
You never told us anything about sscanf.
Reply
#9

You don't need sscanf for commands with only one parameter:
pawn Код:
CMD:san(playerid, params[]) {
    new id = strval(params);
    if(isnull(id)) return SendClientMessage(playerid, -1, "USAGE: /san [id]");
    SetPlayerPos(id, X, Y, Z);
    //SetPlayerFacingAngle(id, Angle); //Optional, but replace 'Angle' with your own float
    return 1;
}
Reply
#10

Normally, you might want to make a check if the player is online.

pawn Код:
CMD:san(playerid, params[]) {
    new id = strval(params);
    if(isnull(id)) return SendClientMessage(playerid, -1, "USAGE: /san [id]");
    if(!IsPlayerConnected(id) || id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "That player is not connected.");
    SetPlayerPos(id, X, Y, Z);
    //SetPlayerFacingAngle(id, Angle); //Optional, but replace 'Angle' with your own float
    return 1;
}
Also, this wouldn't work if you were entering a player's name, you have to enter the ID.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)