This works in another script but not mine? -
Dokins - 13.03.2012
It's to do with SSCANF and mine works in the exact same way, can someone explain why this one: (VORTEX 2) Works.
pawn Код:
else if(strcmp(tool, "Disregard", true) == 0) {
new
userID,
string[128];
if(sscanf(params, "s[16]u", tool, userID)) {
SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/reports disregard [playerid]");
}
But mine; Pretty much the same; Doesnt.
pawn Код:
if(strcmp(usage, "store", true) ==0)
{
if(sscanf(params, "s[24]s[32]",usage,item))
{
SendClientMessage(playerid, COLOUR_GREY, "Usage: /trunk store [item]");
SendClientMessage(playerid, COLOUR_GREY, "Available Items: Weapon, Weed, Cocaine, Money, Armour");
}
ISSUE IS:
The SendClientMessage's do not display for mine, but they do on the first.
Re: This works in another script but not mine? -
eesh - 13.03.2012
pawn Код:
if(strcmp(usage, "store", true) ==0)// correct me but isnt store being checked here already?
{
if(sscanf(params, "s[24]s[32]",usage,item))//you need not have two as the if already checks store :S
{
SendClientMessage(playerid, COLOUR_GREY, "Usage: /trunk store [item]");
SendClientMessage(playerid, COLOUR_GREY, "Available Items: Weapon, Weed, Cocaine, Money, Armour");
}
If you post your command i will rewrite the fixed version for you.
Re: This works in another script but not mine? -
Dokins - 13.03.2012
I guess but can I have a second opinion?
(Bump)
Re: This works in another script but not mine? -
Mike_Peterson - 13.03.2012
second opinion rejected, sorry..
nah just kidding, eesh seems right by the way, remove the s[24] and usage from the sscanf, as it will now check if u type /trunk store store Weed, which I suppose you don't want to be the end result, aye?
while typing this i just noticed that the tool is twice @ vortex's command too.. strange, i'll double check it in a few mins
Re: This works in another script but not mine? -
Dokins - 13.03.2012
Thanks, I have a feeling its to do with it not knowing where a string ends?
Re: This works in another script but not mine? -
Mike_Peterson - 13.03.2012
double checked it, its fine since the sscanf is used for params, so cmd > store > item, now I wonder if it's also possible to try sscanf on 'usage' instead of params, like
pawn Код:
if(sscanf(usage, "s[32]",item))
it's for you to experiment with.
Re: This works in another script but not mine? -
Dokins - 13.03.2012
Still doesn't work.
pawn Код:
if(strcmp(usage, "store", true))
{
if(sscanf(usage, "s[24]",item))
{
SendClientMessage(playerid, COLOUR_GREY, "Usage: /trunk store [item]");
SendClientMessage(playerid, COLOUR_GREY, "Available Items: Weapon, Weed, Cocaine, Money, Armour");
}
Re: This works in another script but not mine? -
Mike_Peterson - 13.03.2012
It still ain' showing any messages up? Show your entire command then, if you could.
edit: i suppose the [24] is so the max character length is 24?
Re: This works in another script but not mine? -
Dokins - 13.03.2012
pawn Код:
CMD:trunk(playerid, params[])
{
if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
new item[32], amount,usage[24], vehicleid = GetClosestVehicle(playerid, 3);
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOUR_GREY, "You must get out of the vehicle to use this.");
if(VehWep1[vehicleid] > 0 && VehWep2[vehicleid] > 0)return SendClientMessage(playerid, COLOUR_GREY, "You do not have any free weapon slots.");
if(sscanf(params, "s[32]",usage))
{
printf("USAGE: %s", usage);
SendClientMessage(playerid, COLOUR_GREY, "Usage: /trunk [usage]");
SendClientMessage(playerid, COLOUR_GREY, "Usages: Store, Get, View");
return 1;
}
VehicleSQLID[vehicleid] = MySQL_GetValue(VehicleSQLID[vehicleid], "id", "vehicles");
if(vehicleid == TrunkOpened[playerid])
{
if(!strcmp(usage, "store", true))
{
printf("USAGE: %s", usage);
if(sscanf(usage, "s[24]",item))
{
printf("USAGE: %s", usage);
printf("ITEM: %s", item);
SendClientMessage(playerid, COLOUR_GREY, "Usage: /trunk store [item]");
SendClientMessage(playerid, COLOUR_GREY, "Available Items: Weapon, Weed, Cocaine, Money, Armour");
}
if(!(strcmp(item, "weapon", true)))
{
new weapon = GetPlayerWeapon(playerid);
new ammo = GetPlayerAmmo(playerid);
new string[128];
if(weapon > 1)
{
if(VehWep1[vehicleid] == 0)
{
VehWep1[vehicleid] = weapon;
VehWepA1[vehicleid] = ammo;
MySQL_SetInteger(VehicleSQLID[vehicleid], "VehWep1", weapon, "vehicles");
MySQL_SetInteger(VehicleSQLID[vehicleid], "VehWepA1", ammo, "vehicles");
RemovePlayerWeapon(playerid, weapon);
format(string, sizeof(string), "You have stored a %s in your vehicles trunk.", WeaponNames[weapon]);
SendClientMessage(playerid, COLOUR_BLUE, string);
format(string, sizeof(string), "* %s has stored a weapon in the %s's trunk.", GetNameEx(playerid), VehicleNames[vehicleid]);
ProxDetector(30.0, playerid, string, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE);
}
else if(VehWep2[vehicleid] == 0)
{
VehWep2[vehicleid] = weapon;
VehWepA2[vehicleid] = ammo;
MySQL_SetInteger(VehicleSQLID[vehicleid], "VehWep2", weapon, "vehicles");
MySQL_SetInteger(VehicleSQLID[vehicleid], "VehWepA2", ammo, "vehicles");
RemovePlayerWeapon(playerid, weapon);
format(string, sizeof(string), "You have stored a %s in your vehicles trunk.", WeaponNames[weapon]);
SendClientMessage(playerid, COLOUR_BLUE, string);
format(string, sizeof(string), "* %s has stored a weapon in the %s's trunk.", GetNameEx(playerid), VehicleNames[vehicleid]);
ProxDetector(30.0, playerid, string, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE);
}
}
}
}
}
return 1;
}
I've posted some prints....it shows... USAGE: (NOTHING HERE) for the first one?!
[15:33:37] USAGE: - Command executed here.
[15:33:13] Admin Connected: Grant McCaw, Count: 1
[15:33:08] Number of vehicle models: 4
Re: This works in another script but not mine? -
[ABK]Antonio - 13.03.2012
Can't you just do something like this?
pawn Код:
CMD:store(playerid, params[])
{
new control[32], item[32], amount[32];
if(sscanf(params, "s[32]S[32]S[32]", control, item, amount)) //error / usage here
if(!strcmp(control, "store", true))
{
if(isnull(item))
{
SendClientMessage(playerid, COLOUR_GREY, "Usage: /trunk store [item]");
SendClientMessage(playerid, COLOUR_GREY, "Available Items: Weapon, Weed, Cocaine, Money, Armour")
}
else if(!strcmp(item, "Weapon", true))
{
//do shit
}
else if(!strcmp(item, "Weed", true))
{
if(isnull(amount)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /trunk store weed <amount>");
new Amount = strval(amount);
if(Amount > MYAMOUNT) return SendClientMessage(playerid, COLOUR_GREY, "You don't have that much!");
//the rest of the code
}
}
return 1;
}