08.07.2016, 15:19
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...
"CMD:pm"
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;
}
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 код:
|
if(matches > 1) return INVALID_PLAYER_ID;
if(matches < 1) return INVALID_PLAYER_ID;
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.
|