PDA

View Full Version : in-game id not working


Hapukoorepakk
08/07/2016, 03:19 PM
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...

diego200052
08/07/2016, 03:20 PM
Search in your code "CMD:pm" or "pm" until you found the command code.

Hapukoorepakk
08/07/2016, 03:23 PM
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.

Dusan01
08/07/2016, 03:31 PM
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: 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 i : Player)
{
// Search for part of the players name
if(strfind(PlayerNames[i], name, true) != -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;
}

diego200052
08/07/2016, 03:33 PM
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: 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 i : Player)
{
// Search for part of the players name
if(strfind(PlayerNames[i], name, true) != -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?

if(matches > 1) return INVALID_PLAYER_ID;

I think it must be:

if(matches < 1) return INVALID_PLAYER_ID;

Dusan01
08/07/2016, 03:42 PM
Here is the problem?

if(matches > 1) return INVALID_PLAYER_ID;

I think it must be:

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

diego200052
08/07/2016, 03:47 PM
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.

Dusan01
08/07/2016, 03:50 PM
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...

Stinged
08/07/2016, 04:00 PM
There is nothing wrong with sscanf's u specifier, I've been using it for years.
Post a command as an example, Hapukoorepakk.

Dusan01
08/07/2016, 04:10 PM
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...