SA-MP Forums Archive
sscanf help = +Rep =S - 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: sscanf help = +Rep =S (/showthread.php?tid=336079)



sscanf help = +Rep =S - GtasaPoliceModz - 21.04.2012

Hello there, I am making a command /load I have made the command and ready to test it put when I do i keep getting a message Player isn't connected. But I add a connect id Any Suggestions || Please help!

Код:
COMMAND:load(playerid, vehicleid, params[])
{
	{
		new LoadName;
		new SenderName[MAX_PLAYER_NAME];
		new PlayerName[MAX_PLAYER_NAME];
		if (!sscanf(params, "u", LoadName))
		{
			if (LoadName == INVALID_PLAYER_ID)
			{
   			SendClientMessage(playerid, COLOR_BRIGHTRED, "(INFO) You have specified an invalid player ID.");
			return 1;
			}
			else
			{
			SendClientMessage(playerid, COLOR_WHITE, "USAGE: /cuff [Player ID]");
			}
		}
        if(gteam[playerid] == 2)
		{
			new string[128];
			GetPlayerName(playerid, SenderName, sizeof(SenderName));
			GetPlayerName(LoadName, PlayerName, sizeof(PlayerName));
		 	PutPlayerInVehicle(LoadName, vehicleid, 3);
			format(string, sizeof(string), "(INFO) You have loaded %s into your ambulance.", LoadName);
			SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
			format(string, sizeof(string), "(INFO) You have been loaded into a ambulance by %s", SenderName);
			SendClientMessage(LoadName, COLOR_LIGHTBLUE, string);
			format(string, sizeof(string), "DISPATCH: %s has loaded %s into the ambulance.", SenderName, LoadName);
			SendFireMessage(COLOR_BRIGHTRED, string);
			TogglePlayerControllable(LoadName, 0);
			return 1;
		}
	}
	return 1;
}



Respuesta: sscanf help = +Rep =S - Francis. - 21.04.2012

pawn Код:
COMMAND:load(playerid, vehicleid, params[])
{
    new LoadName;
    new SenderName[MAX_PLAYER_NAME];
    new PlayerName[MAX_PLAYER_NAME];
    if (sscanf(params, "u", LoadName)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /cuff [Player ID]"),1;
    if(!IsPlayerConnected(LoadName) || LoadName == INVALIR_PLAYER_ID) return SendClientMessage(playerid, COLOR_BRIGHTRED, "(INFO) You have specified an invalid player ID."),1;
    if(gteam[playerid] == 2)
    {
        new string[128];
        GetPlayerName(playerid, SenderName, sizeof(SenderName));
        GetPlayerName(LoadName, PlayerName, sizeof(PlayerName));
        PutPlayerInVehicle(LoadName, vehicleid, 3);
        format(string, sizeof(string), "(INFO) You have loaded %s into your ambulance.", LoadName);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
        format(string, sizeof(string), "(INFO) You have been loaded into a ambulance by %s", SenderName);
        SendClientMessage(LoadName, COLOR_LIGHTBLUE, string);
        format(string, sizeof(string), "DISPATCH: %s has loaded %s into the ambulance.", SenderName, LoadName);
        SendFireMessage(COLOR_BRIGHTRED, string);
        TogglePlayerControllable(LoadName, 0);
        return 1;
    }
    return 1;
}