SA-MP Forums Archive
in-game id not working - 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: in-game id not working (/showthread.php?tid=611581)



in-game id not working - Hapukoorepakk - 08.07.2016

I am writing /pm [id] [text], and then tell the player is not online. Where can I look for a mistake or how specifically the rules of procedure will be? Sorry bad English...


Re: in-game id not working - diego200052 - 08.07.2016

Search in your code
PHP код:
"CMD:pm" 
or "pm" until you found the command code.


Re: in-game id not working - Hapukoorepakk - 08.07.2016

Existing command. All commands operate but will not work with the player id that even if the write / setlevel 4 and 5 it says that the player is not online.


Re: in-game id not working - Dusan01 - 08.07.2016

Mhm, i had same problem with sscanf parameter U, player is online, but after few hour of playing on server, it gets buggy, so i found a fix by ******, just add this to your gamemode:
PHP код:
SSCANF:u(name[])
{
    
// No name specified
    
if(isnull(name)) return INVALID_PLAYER_ID;
    new 
id;
    
// Was a part of name provided?
    
if(sscanf(name"i"id))
    {
        new 
matches;
        
// Find a player return the id
        
foreach(new Player)
        {
            
// Search for part of the players name
            
if(strfind(PlayerNames[i], nametrue) != -1)
            {
                
matches++;
                
id i;
                if(
matches 1) return INVALID_PLAYER_ID;
            }
        }
        
// Found a match
        
if(matches) return id;
        
// No player found return invalid player id
        
return INVALID_PLAYER_ID;
    }
    
// Player supplied a id
    // Make sure the id is greater than 0
    
if(id 0) return INVALID_PLAYER_ID;
    
// Make sure the id is connected
    
if(!IsPlayerConnected(id)) return INVALID_PLAYER_ID;
    
// Return the id
    
return id;




Re: in-game id not working - diego200052 - 08.07.2016

Quote:
Originally Posted by Dusan01
Посмотреть сообщение
Mhm, i had same problem with sscanf parameter U, player is online, but after few hour of playing on server, it gets buggy, so i found a fix by ******, just add this to your gamemode:
PHP код:
SSCANF:u(name[])
{
    
// No name specified
    
if(isnull(name)) return INVALID_PLAYER_ID;
    new 
id;
    
// Was a part of name provided?
    
if(sscanf(name"i"id))
    {
        new 
matches;
        
// Find a player return the id
        
foreach(new Player)
        {
            
// Search for part of the players name
            
if(strfind(PlayerNames[i], nametrue) != -1)
            {
                
matches++;
                
id i;
                if(
matches 1) return INVALID_PLAYER_ID;
            }
        }
        
// Found a match
        
if(matches) return id;
        
// No player found return invalid player id
        
return INVALID_PLAYER_ID;
    }
    
// Player supplied a id
    // Make sure the id is greater than 0
    
if(id 0) return INVALID_PLAYER_ID;
    
// Make sure the id is connected
    
if(!IsPlayerConnected(id)) return INVALID_PLAYER_ID;
    
// Return the id
    
return id;

Here is the problem?

PHP код:
if(matches 1) return INVALID_PLAYER_ID
I think it must be:

PHP код:
if(matches 1) return INVALID_PLAYER_ID



Re: in-game id not working - Dusan01 - 08.07.2016

Quote:
Originally Posted by diego200052
Посмотреть сообщение
Here is the problem?

PHP код:
if(matches 1) return INVALID_PLAYER_ID
I think it must be:

PHP код:
if(matches 1) return INVALID_PLAYER_ID
hmm, i dont think so, what will happen if there is more then 2 results, witch one will select for execute? thats just protection from something... if find 2+ results what should not happen


Re: in-game id not working - diego200052 - 08.07.2016

Quote:
Originally Posted by Dusan01
Посмотреть сообщение
hmm, i dont think so, what will happen if there is more then 2 results, witch one will select for execute? thats just protection from something... if find 2+ results what should not happen
But for example there are two players "Dusan01" and "Trucksan22" if one player writes /u san will found 2 matches and will return invalid id, this only happens if write a part of name but if write complete it's ok.


Re: in-game id not working - Dusan01 - 08.07.2016

Quote:
Originally Posted by diego200052
Посмотреть сообщение
But for example there are two players "Dusan01" and "Trucksan22" if one player writes /u san will found 2 matches and will return invalid id, this only happens if write a part of name but if write complete it's ok.
yeah, okay for that, but 90% of us is using IDs for players, but yeah, he can return something other, like type full name or something like that...

but this fix should work for bug witch he has saying to player is not connected, but he is connected...


Re: in-game id not working - Stinged - 08.07.2016

There is nothing wrong with sscanf's u specifier, I've been using it for years.
Post a command as an example, Hapukoorepakk.


Re: in-game id not working - Dusan01 - 08.07.2016

Quote:
Originally Posted by Stinged
Посмотреть сообщение
There is nothing wrong with sscanf's u specifier, I've been using it for years.
Post a command as an example, Hapukoorepakk.
I used it for years too, and only on 1 gamemode witch i used i had that problem, and same problem was reported to ****** and he sayd he know why is that happening and he posted that fix witch i posted here...