SA-MP Forums Archive
Sscanf help! - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Sscanf help! (/showthread.php?tid=268374)



Sscanf help! - cloudysky - 12.07.2011

pawn Код:
command(goto, playerid, params[])
{
    new admin[25];
    new pid;
    new player[25];
    new string[128];
   
    GetPlayerName(playerid, admin, 25);
    GetPlayerName(pid, player, 25);
    if(sscanf(params, "u", pid)) return SendClientMessage(playerid, COLOUR_WHITE, "Hint: /goto [Playerid/Name]");
    if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, COLOUR_WHITE, "That player is not connected.");
    new Float:px, Float:py, Float:pz;
    GetPlayerPos(pid, px, py, pz );
    SetPlayerPos(playerid, px, py, pz );
    format(string, sizeof(string),"**You have successfully teleported to %s!**",player);
    SendClientMessage(playerid, COLOUR_TAN,string);
    return 1;
}
Thats my command everything works apart from it says "You've teleported to Cloudysky" even if you teleport to someone else.


Re: Sscanf help! - Edvin - 12.07.2011

pawn Код:
format(string, sizeof(string),"**You have successfully teleported to %s!**",pid;
SendClientMessage(playerid, COLOUR_TAN,string);
try this:P


Re: Sscanf help! - Roko_foko - 12.07.2011

Quote:
Originally Posted by cloudysky
Посмотреть сообщение
pawn Код:
command(goto, playerid, params[])
{
    new admin[25];
    new pid;
    new player[25];
    new string[128];
   
    GetPlayerName(playerid, admin, 25);
    GetPlayerName(pid, player, 25);
    if(sscanf(params, "u", pid)) return SendClientMessage(playerid, COLOUR_WHITE, "Hint: /goto [Playerid/Name]");
    if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, COLOUR_WHITE, "That player is not connected.");
    new Float:px, Float:py, Float:pz;
    GetPlayerPos(pid, px, py, pz );
    SetPlayerPos(playerid, px, py, pz );
    format(string, sizeof(string),"**You have successfully teleported to %s!**",player);
    SendClientMessage(playerid, COLOUR_TAN,string);
    return 1;
}
Thats my command everything works apart from it says "You've teleported to Cloudysky" even if you teleport to someone else.
Delete "GetPlayerName(pid, player, 25);" and put it before "format(string, sizeof(string),"**You have successfully teleported to %s!**",player);".


Re: Sscanf help! - cloudysky - 12.07.2011

Quote:
Originally Posted by Roko_foko
Посмотреть сообщение
Delete "GetPlayerName(pid, player, 25);" and put it before "format(string, sizeof(string),"**You have successfully teleported to %s!**",player);".
Thanks it worked.

One more question is my server.exe I get this message when using my Kick Command.

"Strings without a length are depreciated please add a destination size."

pawn Код:
command(kick, playerid, params[])
{
    new admin[25];
    new pid;
    new player[25];
    new reason[128];
    new string[128];
   
    GetPlayerName(playerid, admin, 25);
    if(sscanf(params, "us", pid, reason)) return SendClientMessage(playerid, COLOUR_WHITE, "Hint: /kick [Playerid/Name] [Reason]");
    if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, COLOUR_WHITE, "That player ID is not connected.");
    GetPlayerName(pid, player, 25);
    format(string, sizeof(string),"**Server Admin %s has kicked %s. Reason: %s.**",admin, player, reason);
    SendClientMessageToAll(COLOUR_ALERT,string);
    SendClientMessage(pid, COLOUR_WHITE, "You have been kicked!" );
    Kick(pid);
    return 1;
}



Re: Sscanf help! - Vince - 12.07.2011

pawn Код:
if(sscanf(params, "us[128]", pid, reason))