Argument Type Mismatch
#1

Y'all probably think i'm a dumbass for not figuring this out, and requiring help with something soo simple. Well, you're probably right xD (I stopped coding for a while and lost quite a bit of it, IE the reason for all the help threads recently, oh well :P)

On topic, I got an argument type mismatch to set the enum value for my vehicles.

pawn Код:
CMD:vowner(playerid, params[])
    {
    if(PlayerInfo[playerid][pAdmin] >=4)
        {
        new vehicleid, opid[30];
        if(sscanf(params, "dd", vehicleid, opid))
            {
            UsageMessage(playerid, "/vowner [vehicleid] [playerid]");
            return 1;
            }
        else
            {
            new string[30];
            new name[30];
            GetPlayerName(opid, name, sizeof(name));
            format(string, sizeof(string), "%s", name); //ERROR IS THIS LINE!
            VehicleInfo[vehicleid][vOwner] = string;
            SCM(pid, COLGREEN, "Server: {F0F0F0}You have set the owner of this vehicle.");
            return 1;
            }
        }
    return 1;
    }
It works if I use the stock I created, GetName(playerid) (which also removes the _ from the name)...But if I try GetName(opid) I get the error.
Reply
#2

It's since opid is a string, not a player id.
You could possibly use a loop, or (this was not created by me):
pawn Код:
stock RPIDFN(playername[])
{
  for(new i = 0; i <= MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(i))
    {
      new playername2[MAX_PLAYER_NAME];
      GetPlayerName(i, playername2, sizeof(playername2));
      if(strcmp(playername2, playername, true, strlen(playername)) == 0)
      {
        return i;
      }
    }
  }
  return INVALID_PLAYER_ID;
}
And GetName(RPIDFN(opid));
Reply
#3

I dunno what the hell I was thinking to define it as a string lol, I changed
pawn Код:
new opid[30];
to
pawn Код:
new opid;
and GetName(opid). All is good now, +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)