/agivelicense( problem - 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: /agivelicense( problem (
/showthread.php?tid=564515)
/agivelicense( problem -
qUneT - 21.02.2015
Hey guys, can you help me with this code?
Код:
CMD:agivelicense(playerid, params[])
{
new id, option[7];// string[128];
if(PlayerInfo[playerid][pAdminLevel] < 4) return FaraAcces;
if(sscanf(params, "ui", id, option)) return SendClientMessage(playerid, 0xFFFFFFFF, "Folosire: {C0C0C0}/agivelicense [playerid] [Type] (Type 1 = Car | Type 2 = Weapon | Type 3 = Boat | Type 4 = Fly)");
{
if(!strcmp(option, "1", true))
{
SendClientMessage(playerid,-1,"Test Car");
return 1;
}
else if(strcmp(option, "2", true))
{
SendClientMessage(playerid,-1,"Test Weapon ");
return 1;
}
else if(strcmp(option, "3", true))
{
SendClientMessage(playerid,-1,"Test Boat");
return 1;
}
else if(strcmp(option, "4", true))
{
SendClientMessage(playerid,-1,"Test Fly");
return 1;
}
}
return 1;
}
Re: /agivelicense( problem -
CalvinC - 21.02.2015
You're trying to use "option" as an integer in sscanf, but when defining "option" you add a string size, and try to use strcmp to compare it like a normal string.
Here's a fixed version, using a switch to compare the integer:
pawn Код:
CMD:agivelicense(playerid, params[])
{
new id, option;// string[128];
if(PlayerInfo[playerid][pAdminLevel] < 4) return FaraAcces;
if(sscanf(params, "ui", id, option)) return SendClientMessage(playerid, 0xFFFFFFFF, "Folosire: {C0C0C0}/agivelicense [playerid] [Type] (Type 1 = Car | Type 2 = Weapon | Type 3 = Boat | Type 4 = Fly)");
switch(option)
{
case 1: return SendClientMessage(playerid,-1,"Test Car");
case 2: return SendClientMessage(playerid,-1,"Test Weapon ");
case 3: return SendClientMessage(playerid,-1,"Test Boat");
case 4: return SendClientMessage(playerid,-1,"Test Fly");
}
return 1;
}
Re: /agivelicense( problem -
qUneT - 21.02.2015
Wow ty i +rep you.