Argument Type Mismatch - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Argument Type Mismatch (
/showthread.php?tid=467043)
Argument Type Mismatch -
Mattakil - 30.09.2013
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.
Re: Argument Type Mismatch -
bensmart469 - 30.09.2013
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));
Re: Argument Type Mismatch -
Mattakil - 30.09.2013
I dunno what the hell I was thinking to define it as a string lol, I changed
to
and GetName(opid). All is good now, +rep