SA-MP Forums Archive
loc command - 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: loc command (/showthread.php?tid=317301)



loc command - Face9000 - 10.02.2012

Hello,i've maked this loc command. (Show location of player)

pawn Код:
CMD:loc(playerid, params[])
{
if(IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xFF0000FF,"You can't use this command when you are dead or spawning.");
if(isnull(params))return SendClientMessage(playerid, 0xFF0000FF, "Usage: /loc [playerid]");
new target, current_zone;
current_zone = player_zone[target];
if(current_zone != -1 && IsPlayerConnected(target)) {
new playername[MAX_PLAYER_NAME],message2[170];
GetPlayerName(target,playername,MAX_PLAYER_NAME);
format(message2,sizeof(message2),"%s(%d)'s current location: %s",playername,target,zones[current_zone][zone_name]);
SendClientMessage(playerid,0x00C7FFAA,message2);
} else {
SendClientMessage(playerid,red,"Invalid Player ID");
}
return true;
}
I've some problems.

It shows location ONLY at id 0,so if i type /loc 1,2,3 etc... it shows only player id 0 location.
If i type an invalid id (ex: player offline),it shows again id 0.

What's wrong?


Re: loc command - SnG.Scot_MisCuDI - 10.02.2012

This happened to me but it was solved by updating sscanf


Re: loc command - Face9000 - 10.02.2012

My sscanf is updated.


Re: loc command - Nuke547 - 10.02.2012

This should work:

PHP код:
CMD:loc(playeridparams[])
{
    new 
id;
    new 
targetcurrent_zone;
    
current_zone player_zone[target];
    if(
sscanf(params"u"id))
    {
        
SendClientMessage(playerid0xFF0000FF"Usage: /loc [playerid]");
    }
    else
    {
        if(
current_zone != -&& IsPlayerConnected(target))
        {
            new 
playername[MAX_PLAYER_NAME],message2[170];
            
GetPlayerName(id,playername,MAX_PLAYER_NAME);
            
format(message2,sizeof(message2),"%s(%d)'s current location: %s",playername,target,zones[current_zone][zone_name]);
            
SendClientMessage(playerid,0x00C7FFAA,message2);
        }
        else
        {
            
SendClientMessage(playerid,red,"Invalid Player ID");
        }
    }




Re: loc command - SnG.Scot_MisCuDI - 11.02.2012

not sure if this will change anything
pawn Код:
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, red, "USAGE: /loc [playerid]");



Re: loc command - Tanush123 - 11.02.2012

Quote:
Originally Posted by Nuke547
Посмотреть сообщение
This should work:

PHP код:
CMD:loc(playeridparams[])
{
    new 
id;
    new 
targetcurrent_zone;
    
current_zone player_zone[target];
    if(
sscanf(params"u"id))
    {
        
SendClientMessage(playerid0xFF0000FF"Usage: /loc [playerid]");
    }
    else
    {
        if(
current_zone != -&& IsPlayerConnected(target))
        {
            new 
playername[MAX_PLAYER_NAME],message2[170];
            
GetPlayerName(id,playername,MAX_PLAYER_NAME);
            
format(message2,sizeof(message2),"%s(%d)'s current location: %s",playername,target,zones[current_zone][zone_name]);
            
SendClientMessage(playerid,0x00C7FFAA,message2);
        }
        else
        {
            
SendClientMessage(playerid,red,"Invalid Player ID");
        }
    }

Quote:
Originally Posted by googamalugafoo
Посмотреть сообщение
not sure if this will change anything
pawn Код:
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, red, "USAGE: /loc [playerid]");
Googamalugafoo, well that is actually a better coded way than the one above


Re: loc command - SnG.Scot_MisCuDI - 11.02.2012

Quote:
Originally Posted by Tanush123
Посмотреть сообщение
Googamalugafoo, well that is actually a better coded way than the one above
yeah i dont understand why he made it on multiple lines when it can be on one lol


Re: loc command - Twisted_Insane - 11.02.2012

Delete your "return true;", and let only the "else"-statement be at the end!