Problem Fast[Rep]
#9

Quote:
Originally Posted by ArmyOps
Посмотреть сообщение
pawn Код:
public OnPlayerCommandText(playerid,cmdtext[])
{
    if(!strcmp(cmdtext,"/cityhall",true))
    {            
        SetPlayerPos(playerid,1221.1116,-1814.8745,16.5938);
        return 1;
    }
    return 0;
}
This is wrong. He wants to send a targetid to the cityhall. Not himself.

This is using ZCMD and sscanf. You should use it. It is fast, easy, and much more practical than using a string comparer as a command processor.

pawn Код:
CMD:cityhall(playerid,params[])
{
    new targetid;
    if(!IsPlayerAdmin(playerid)) //This is an Admin-Only command.
    {
        return SendClientMessage(playerid,0xFFFFFFFF,"  You are not authorized to use that command.");
    }
    if(sscanf(params,"i",targetid))
    {
        return SendClientMessage(playerid,0xFFFFFFFF,"USAGE: /cityhall [playerid]");
    }
    if(i == INVALID_PLAYER_ID)
    {
        return SendClientMessage(playerid,0xFFFFFFFF,"Player not found.");
    }
    else
    {
        new Admin[24],string[50];
        GetPlayerName(playerid,Admin,sizeof(Admin));
        format(string,sizeof(string),"Administrator %s has teleported you to City Hall.");
        SendClientMessage(targetid,0xFFFFFFFF,string);
        SetPlayerPos(targetid,1221.1116,-1814.8745,16.5938);
        return 1;
    }
    return 1;
}
Go check out those ZCMD and sscanf tutorials man.
Reply


Messages In This Thread
Problem Fast[Rep] - by Dan_Barocu - 27.02.2012, 22:12
Re: Problem Fast[Rep] - by ArmyOps - 27.02.2012, 22:14
Re: Problem Fast[Rep] - by Dan_Barocu - 27.02.2012, 22:15
Re: Problem Fast[Rep] - by ArmyOps - 27.02.2012, 22:22
Re: Problem Fast[Rep] - by Dan_Barocu - 27.02.2012, 22:25
Re: Problem Fast[Rep] - by ArmyOps - 27.02.2012, 22:29
Re: Problem Fast[Rep] - by Dan_Barocu - 27.02.2012, 22:35
Re: Problem Fast[Rep] - by Dan_Barocu - 27.02.2012, 22:50
Re: Problem Fast[Rep] - by Walsh - 27.02.2012, 22:52
Re: Problem Fast[Rep] - by Dan_Barocu - 27.02.2012, 22:56

Forum Jump:


Users browsing this thread: 1 Guest(s)