13.03.2012, 18:53
as already pointed out, the optional sscanf S()[] specifier is a neat way to do this:
by creating a custom specifier which recognizes a string, and returns a numerical value (1 for weapon, 1 for weed etc), this spaghetti like snippet would look better
not tested btw...
pawn Код:
if(sscanf(params, "s[32]S()[32]",usage,item))
{
SendClientMessage(playerid, COLOUR_GREY, "Usage: /trunk [usage]");
SendClientMessage(playerid, COLOUR_GREY, "Usages: Store, Get, View");
}
printf("USAGE:%s ITEM:%s", usage,item);
VehicleSQLID[vehicleid] = MySQL_GetValue(VehicleSQLID[vehicleid], "id", "vehicles");
if(vehicleid == TrunkOpened[playerid])
{
if(!strcmp(usage, "store", true))
{
if(!strcmp(item, "weapon", true))
{
}
else if(!strcmp(item, "weed", true))
{
}
else if(!strcmp(item, "cocaine", true))
{
}
else if(!strcmp(item, "money", true))
{
}
else if(!strcmp(item, "armor", true))
{
}
}
else if(!strcmp(item, "get", true)
{
if(!strcmp(item, "weapon", true))
{
}
else if(!strcmp(item, "weed", true))
{
}
else if(!strcmp(item, "cocaine", true))
{
}
else if(!strcmp(item, "money", true))
{
}
else if(!strcmp(item, "armor", true))
{
}
}
else if(!strcmp(item, "view", true)
{
if(!strcmp(item, "weapon", true))
{
}
else if(!strcmp(item, "weed", true))
{
}
else if(!strcmp(item, "cocaine", true))
{
}
else if(!strcmp(item, "money", true))
{
}
else if(!strcmp(item, "armor", true))
{
}
}
else
{
SendClientMessage(playerid, COLOUR_GREY, "Usage: /trunk store [item]");
SendClientMessage(playerid, COLOUR_GREY, "Available Items: Weapon, Weed, Cocaine, Money, Armour");
}
not tested btw...