[FIXED]jetpack cmd
#1

The code works opposite,instead of showing me you have spawned jetpack it shows me the other message i set for player.

Код:
CMD:jetpack(playerid,params[])
{
    new string[128],id,pName[MAX_PLAYER_NAME];
	if(PInfo[playerid][Level] < 3)
    return SendClientMessage(playerid,STEALTH_BLUE,"You need to be level 3 to give jetpacks.");
    if(sscanf(params,"us",id))
	{
		if(!IsPlayerConnected(id))
		return SendClientMessage(playerid,STEALTH_BLUE,"That player is not connected!");
		GetPlayerName(playerid,pName,sizeof pName);
		format(string,sizeof(string),"Administrator %s(ID:%d) has given you a jetpack.",pName,id);
		SendClientMessage(id,COLOR_DARKORCHID,string);
		SetPlayerSpecialAction(id, SPECIAL_ACTION_USEJETPACK);
	}
	else
    {
		SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USEJETPACK);
		SendClientMessage(playerid,STEALTH_OLIVE,"Jetpack Spawned!");
		SendClientMessage(playerid,STEALTH_OLIVE,"Want to give player a jetpack? Use /jetpack [ID]");
	}
	return 1;
}
Reply
#2

pawn Код:
if(sscanf(params,"us",id))
should be

pawn Код:
if(!sscanf(params,"u",id))
since "u" stands for user, "s" stands for string and you are only expecting one result, the "id". Also, as far as I know "s" is deprecated and must be used as "s[<size>]". Check this out for more details: https://github.com/Y-Less/sscanf/wiki#more-specifiers
Reply
#3

First, the functions you put after sscanf will trigger if you do not write the needed parameters.
pawn Код:
if(sscanf(params,"us",id)) return SendClientMessage(playerid, -1, "/jetpack [ID]");
Second, you are using "us", but yet only "id", remove the "s" string parameter.
Reply
#4

Thanks i always make mistakes with this specifiers ._.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)