error 035: argument type mismatch (argument 1)
if(IsPlayerConnected(GetPlayerID(targetid))) // ERROR
stock GetPlayerID(playername[])
{
for(new i=GetPlayerPoolSize(); i != -1; i--)
{
if(IsPlayerConnected(i))
{
if(strcmp(GetPlayerName(i), playername, true, strlen(playername)) == 0)
{
return i;
}
}
}
return INVALID_PLAYER_ID;
}
new targetid[MAX_PLAYER_NAME], reason[50];
if(sscanf(params, "s[24]s[50]", targetid, reason))
stock IsOnline(text[])
{
new
strPos,
returnID = 0,
bool: isnum = true;
while(text[strPos]) {
if(isnum) {
if('0' <= text[strPos] <= '9') returnID = (returnID * 10) + (text[strPos] - '0');
else isnum = false;
}
strPos++;
}
if(isnum) {
if(IsPlayerConnected(returnID)) return returnID;
}
else {
new
sz_playerName[MAX_PLAYER_NAME];
foreach(Player, i) {
GetPlayerName(i, sz_playerName, MAX_PLAYER_NAME);
if(!strcmp(sz_playerName, text, true, strPos)) return i;
}
}
return INVALID_PLAYER_ID;
}
// Later on:
new target = IsOnline(targetid);
if(IsPlayerConnected(target))
{
...
}
PHP код:
|
new targetid[MAX_PLAYERS_NAME];
if(sscanf(params, "s[24]", targetid))
serious ?
PHP код:
|
can you explain what's wrong in his code? Because I can't find why he can't use reason?
|
GetID(name[])
{
for(new i, j = GetPlayerPoolSize(); i <= j; i++) // or foreach(new i : Player)
{
if(!strcmp(GetName(i), name, true)) return i;
}
return INVALID_PLAYER_ID;
}
GetName(playerid)
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
return pName;
}
You doubt in the 'SA-MP Lead Scripter' code? How dare you?!
OT: Just use the specifier in the sscanf check, You can use both ID and player name in the sscanf's specifier 'u'. That if you are trying for example kick a player by his name. Why all that? Just use this; PHP код:
|
Yep using 'u' makes lot more sense
![]() |
stock GetPlayerID(playername[])
{
for(new i=GetPlayerPoolSize(); i != -1; i--)
{
if(strcmp(GetPlayerName(i), playername, true, strlen(playername)) == 0) return i;
}
return INVALID_PLAYER_ID;
}