/agivelicense( problem
#1

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;
}
Reply
#2

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;
}
Reply
#3

Wow ty i +rep you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)