Params problem
#1

Hey this is my command I've transferd to the script with no zcmd , And the only one errors iis that :
Код:
Undefinde symbol Params...
Код:
    	if(strcmp(cmd, "/revive", true) == 0)
{
	if(PlayerInfo[playerid][pAdmin] >= 3)
	{
		new string[128], giveplayerid;
		if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /revive [playerid]");

		if(IsPlayerConnected(giveplayerid))
		{
			if(GetPVarInt(giveplayerid, "Injured") == 1)
			{
				format(string, sizeof(string), " You have revived %s.", GetPlayerName(giveplayerid));
				SendClientMessage(playerid, COLOR_WHITE, string);
				SendClientMessage(giveplayerid, COLOR_WHITE, "You have been revived by an Admin.");

   				ClearAnimations(giveplayerid);
   				SetPlayerHealth(giveplayerid, 100);
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD2, "That player is not injured!");
			}
		}
	}
	else
	{
		SendClientMessage(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
	}
	return 1;
}
Reply
#2

For 'params', you must use (for example) ZCMD and not the old, slow strcmp&OnPlayerCommandText!
Reply
#3

What should I do for enter that command ?!
Reply
#4

Well, convert it to ZCMD.
pawn Код:
CMD:revive(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 3)
    {
        new string[128], giveplayerid;
        if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /revive [playerid]");

        if(IsPlayerConnected(giveplayerid))
        {
            if(GetPVarInt(giveplayerid, "Injured") == 1)
            {
                format(string, sizeof(string), " You have revived %s.", GetPlayerName(giveplayerid));
                SendClientMessage(playerid, COLOR_WHITE, string);
                SendClientMessage(giveplayerid, COLOR_WHITE, "You have been revived by an Admin.");

                ClearAnimations(giveplayerid);
                SetPlayerHealth(giveplayerid, 100);
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD2, "That player is not injured!");
            }
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
    }
    return 1;
}
this should od the job.
Reply
#5

Quote:
Originally Posted by yaron0600
Посмотреть сообщение
What should I do for enter that command ?!
Use ZCMD
Then
Код:
    	if(strcmp(cmd, "/revive", true) == 0)
Will become
Код:
CMD:revive(playerid, params[])
Reply
#6

LOL , YOu think I cant do that ?! ALL MY SCRIPT IS if(strcmp(cmd, "/cmd", true) == 0)
Reply
#7

Then don't do it and find a nother way to check those parameters.. strtok, for example. If you use this slow strcmp, why not use slow strtok too?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)