argument type mismatch (argument 1)
#1

PHP код:
error 035argument type mismatch (argument 1)
if(
IsPlayerConnected(GetPlayerID(targetid))) // ERROR
stock GetPlayerID(playername[])
{
  for(new 
i=GetPlayerPoolSize(); != -1i--)
  {
    if(
IsPlayerConnected(i))
    {
      if(
strcmp(GetPlayerName(i), playernametruestrlen(playername)) == 0)
      {
        return 
i;
      }
    }
  }
  return 
INVALID_PLAYER_ID;

ї?,
Reply
#2

if(IsPlayerConnected(GetPlayerID(targetid))) could you show me what you are using for 'targetid' ?
Reply
#3

You have to pass a string, by 'targetid' I assume you're passing a Integer.
Reply
#4

PHP код:
new targetid[MAX_PLAYER_NAME], reason[50];

if(
sscanf(params"s[24]s[50]"targetidreason)) 
Reply
#5

PHP код:
stock IsOnline(text[])
{
    new
        
strPos,
        
returnID 0,
        
boolisnum 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(
Playeri) {
            
GetPlayerName(isz_playerNameMAX_PLAYER_NAME);
            if(!
strcmp(sz_playerNametexttruestrPos)) return i;
        }
    }
    return 
INVALID_PLAYER_ID;
}
// Later on:
new target IsOnline(targetid);
if(
IsPlayerConnected(target))
{
      ...

Reply
#6

Quote:
Originally Posted by Cerealguy
Посмотреть сообщение
PHP код:
new targetid[MAX_PLAYER_NAME], reason[50];
if(
sscanf(params"s[24]s[50]"targetidreason)) 
serious ?

PHP код:
new targetid[MAX_PLAYERS_NAME];
if(
sscanf(params"s[24]"targetid)) 
Reply
#7

Quote:
Originally Posted by Yaa
Посмотреть сообщение
serious ?

PHP код:
new targetid[MAX_PLAYERS_NAME];
if(
sscanf(params"s[24]"targetid)) 
can you explain what's wrong in his code? Because I can't find why he can't use reason?
Reply
#8

Quote:
Originally Posted by AroseKhanNiazi
Посмотреть сообщение
can you explain what's wrong in his code? Because I can't find why he can't use reason?
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.


Quote:
Originally Posted by iamjems
Посмотреть сообщение
PHP код:
// woah 
Why all that? Just use this;

PHP код:
GetID(name[])
{
    for(new 
iGetPlayerPoolSize(); <= ji++) // or foreach(new i : Player)
    
{
        if(!
strcmp(GetName(i), nametrue)) return i;
    }
    return 
INVALID_PLAYER_ID;
}
GetName(playerid)
{
    new 
pName[MAX_PLAYER_NAME];
    
GetPlayerName(playeridpNameMAX_PLAYER_NAME);
    return 
pName;

Reply
#9

Yep using 'u' makes lot more sense or 'r' if you don't wanna include NPC's in it.
Reply
#10

Quote:
Originally Posted by oMa37
Посмотреть сообщение
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 код:
GetID(name[])
{
    for(new 
iGetPlayerPoolSize(); <= ji++) // or foreach(new i : Player)
    
{
        if(!
strcmp(GetName(i), nametrue)) return i;
    }
    return 
INVALID_PLAYER_ID;
}
GetName(playerid)
{
    new 
pName[MAX_PLAYER_NAME];
    
GetPlayerName(playeridpNameMAX_PLAYER_NAME);
    return 
pName;

Quote:
Originally Posted by AroseKhanNiazi
Посмотреть сообщение
Yep using 'u' makes lot more sense or 'r' if you don't wanna include NPC's in it.
thanks bro's!, fix.

PHP код:
stock GetPlayerID(playername[])
{
  for(new 
i=GetPlayerPoolSize(); != -1i--)
  {
      if(
strcmp(GetPlayerName(i), playernametruestrlen(playername)) == 0) return i;
  }
  return 
INVALID_PLAYER_ID;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)