SA-MP Forums Archive
[FIXED]jetpack cmd - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [FIXED]jetpack cmd (/showthread.php?tid=563827)



[FIXED]jetpack cmd - Nabster - 17.02.2015

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;
}



Re: jetpack cmd - HazardouS - 17.02.2015

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


Re: jetpack cmd - CalvinC - 17.02.2015

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.


Re: jetpack cmd - Nabster - 17.02.2015

Thanks i always make mistakes with this specifiers ._.