21.10.2011, 10:45
Hello guys.
I'm having trouble with this sscanf code.
See how I ask if the action is so and so.. and then at the end I have "else return SendClientMessage(playerid, COLOR_GREY, "* Invalid syntax !");
"... well it doesn't send that. I want it too, if action doesn't equal whatever I have put in above. Instead, it keeps sending me "SendClientMessage(playerid, COLOR_GREY, "* Usuage: /car put cash [amount]");"
I'm having trouble with this sscanf code.
pawn Код:
dcmd_car(playerid, params[])
{
if(PlayerInfo[playerid][pOwnsCar] == 0) return SendClientMessage(playerid, COLOR_GREY, "* You do not own a vehicle!");
new check = 0;
new car, vehicle,string[126];
new vehicle1 = CarInfo[PlayerInfo[playerid][pVehicle]][ownedvehicle];
new vehicle2 = CarInfo[PlayerInfo[playerid][pVehicle2]][ownedvehicle];
if(IsABike(vehicle)) return SendClientMessage(playerid, COLOR_GREY, "* Bikes do not have storage.");
new action[128], item[128], amount;
if(sscanf(params, "s[128]S[128]D(0)", action, item, amount))
{
SendClientMessage(playerid, COLOR_GREY, "* Usuage: /car [syntax]");
SendClientMessage(playerid, COLOR_GRAD2, "* Syntax: Check");
SendClientMessage(playerid, COLOR_GRAD3, "* Syntax: Put - cash pot crack mats weapon");
SendClientMessage(playerid, COLOR_GRAD4, "* Syntax: Get - cash pot crack mats weapon");
return 1;
}
new Float:vX, Float:vY, Float:vZ;
GetVehiclePos(vehicle1, vX, vY, vZ);
new Float:vvX, Float:vvY, Float:vvZ;
GetVehiclePos(vehicle2, vvX, vvY, vvZ);
if(IsPlayerInRangeOfPoint(playerid, 5.0, vX, vY, vZ))
{
check = 1;
car = PlayerInfo[playerid][pVehicle];
}
else if(IsPlayerInRangeOfPoint(playerid, 5.0, vvX, vvY, vvZ))
{
check = 1;
car = PlayerInfo[playerid][pVehicle2];
}
if(!check) return SendClientMessage(playerid, COLOR_GREY, "* You are not near any of your vehicles.");
if(strcmp(action, "check") == 0)
{
new pot, crack, mats, cash;
pot = CarInfo[car][vPot], crack = CarInfo[car][vCrack], mats = CarInfo[car][vMats], cash = CarInfo[car][vCash];
SendClientMessage(playerid, COLOR_GREY, "_____________________ Car Storage _____________________");
format(string, sizeof(string), "Crack: %d - Pot: %d - Materials: %d, Cash: %d", crack, pot, mats, cash);
DisplayCarGuns(playerid);
SendClientMessage(playerid, COLOR_GRAD2, string);
return 1;
}
if(strcmp(action, "put") == 0)
{
if(strcmp(item, "cash", true) == 0)
{
if(amount == 0) return SendClientMessage(playerid, COLOR_GREY, "* Usuage: /car put cash [amount]");
if(amount < 0) return SendClientMessage(playerid, COLOR_GREY, "* Usuage: /car put cash [amount]");
new cash = PlayerInfo[playerid][pCash];
if(amount > cash) return SendClientMessage(playerid, COLOR_GREY, "* You do not have that much Cash !");
CarInfo[car][vCash] += amount;
format(string, sizeof(string), "* %s takes out something from his pocket and stores it into his vehicle.", PlayerName(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
PlayerInfo[playerid][pCash] -= amount;
format(string, sizeof(string), "New amount after adding %d cash: %d", amount, CarInfo[car][vCash]);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
return 1;
}
if(strcmp(item, "pot", true) == 0)
{
if(amount == 0) return SendClientMessage(playerid, COLOR_GREY, "* Usuage: /car put pot [amount]");
if(amount < 0) return SendClientMessage(playerid, COLOR_GREY, "* Usuage: /car put pot [amount]");
new pot = PlayerInfo[playerid][pPot];
if(amount > pot) return SendClientMessage(playerid, COLOR_GREY, "* You do not have that much Pot !");
CarInfo[car][vPot] += amount;
format(string, sizeof(string), "* %s takes out something from his pocket and stores it into his vehicle.", PlayerName(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
PlayerInfo[playerid][pPot] -= amount;
format(string, sizeof(string), "New amount after adding %d pot: %d", amount, CarInfo[car][vPot]);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
return 1;
}
if(strcmp(item, "crack", true) == 0)
{
if(amount == 0) return SendClientMessage(playerid, COLOR_GREY, "* Usuage: /car put crack [amount]");
if(amount < 0) return SendClientMessage(playerid, COLOR_GREY, "* Usuage: /car put crack [amount]");
new crack = PlayerInfo[playerid][pCrack];
if(amount > crack) return SendClientMessage(playerid, COLOR_GREY, "* You do not have that much Crack !");
CarInfo[car][vCrack] += amount;
format(string, sizeof(string), "* %s takes out something from his pocket and stores it into his vehicle.", PlayerName(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
PlayerInfo[playerid][pCrack] -= amount;
format(string, sizeof(string), " New amount after adding %d crack: %d", amount, CarInfo[car][vCrack]);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
return 1;
}
if(strcmp(item, "mats", true) == 0)
{
if(amount == 0) return SendClientMessage(playerid, COLOR_GREY, "* Usuage: /car put mats [amount]");
if(amount < 0) return SendClientMessage(playerid, COLOR_GREY, "* Usuage: /car put mats [amount]");
new mats = PlayerInfo[playerid][pMats];
if(amount > mats) return SendClientMessage(playerid, COLOR_GREY, "* You do not have that many Materials !");
CarInfo[car][vMats] += amount;
format(string, sizeof(string), "* %s takes out something from his pocket and stores it into his vehicle.", PlayerName(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
PlayerInfo[playerid][pMats] -= amount;
format(string, sizeof(string), " New amount after adding %d materials: %d", amount, CarInfo[car][vMats]);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
return 1;
}
if(strcmp(item, "weapon", true) == 0)
{
new gunid = GetPlayerWeapon(playerid);
if(gunid == 0)
{
SendClientMessage(playerid, COLOR_GREY, "* You are not holding a weapon.");
return 1;
}
if(CarInfo[car][vGun1] == 0)
{
CarInfo[car][vGun1] = gunid;
format(string, sizeof(string), "* %s takes a weapon and puts it into their car.", PlayerName(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have stored a weapon in Slot 1.");
TakeWeapon(playerid, gunid);
return 1;
}
else if(CarInfo[car][vGun2] == 0)
{
CarInfo[car][vGun2] = gunid;
format(string, sizeof(string), "* %s takes a weapon and puts it into their car.", PlayerName(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have stored a weapon in Slot 2.");
TakeWeapon(playerid, gunid);
return 1;
}
else if(CarInfo[car][vGun3] == 0)
{
CarInfo[car][vGun3] = gunid;
format(string, sizeof(string), "* %s takes a weapon and puts it into their car.", PlayerName(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have stored a weapon in Slot 3.");
TakeWeapon(playerid, gunid);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, "* You have no weapon space left.");
return 1;
}
}
else SendClientMessage(playerid, COLOR_GRAD3, "* Syntax: Put - cash pot crack mats weapon");
return 1;
}
if(strcmp(action, "get") == 0)
{
if(strcmp(item, "cash") == 0)
{
if(amount == 0) return SendClientMessage(playerid, COLOR_GREY, "* Usuage: /car get cash [amount]");
if(amount < 0) return SendClientMessage(playerid, COLOR_GREY, "* Usuage: /car get cash [amount]");
new cash = CarInfo[car][vCash];
if(amount > cash) return SendClientMessage(playerid, COLOR_GREY, "* Your car does not have that much Cash !");
CarInfo[car][vCash] -= amount;
format(string, sizeof(string), "* %s takes out something from his vehicle.", PlayerName(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
PlayerInfo[playerid][pCash] += amount;
format(string, sizeof(string), " New amount taking %d cash: %d", amount, CarInfo[car][vCrack]);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
return 1;
}
if(strcmp(item, "pot") == 0)
{
new pot = CarInfo[car][vPot];
if(amount == 0) return SendClientMessage(playerid, COLOR_GREY, "* Usuage: /car get pot [amount]");
if(amount < 0) return SendClientMessage(playerid, COLOR_GREY, "* Usuage: /car get pot [amount]");
if(amount > pot) return SendClientMessage(playerid, COLOR_GREY, "* Your car does not have that much Pot !");
CarInfo[car][vPot] -= amount;
format(string, sizeof(string), "* %s takes out something from his vehicle.", PlayerName(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
PlayerInfo[playerid][pPot] += amount;
format(string, sizeof(string), "New amount after taking %d pot: %d", amount, CarInfo[car][vPot]);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
return 1;
}
if(strcmp(item, "crack") == 0)
{
if(amount == 0) return SendClientMessage(playerid, COLOR_GREY, "* Usuage: /car get crack [amount]");
if(amount < 0) return SendClientMessage(playerid, COLOR_GREY, "* Usuage: /car get crack [amount]");
new crack = CarInfo[car][vCrack];
if(amount > crack) return SendClientMessage(playerid, COLOR_GREY, "* Your car does not have that much Crack !");
CarInfo[car][vCrack] -= amount;
format(string, sizeof(string), "* %s takes out something from his vehicle.", PlayerName(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
PlayerInfo[playerid][pCrack] += amount;
format(string, sizeof(string), " New amount taking %d crack: %d", amount, CarInfo[car][vCrack]);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
return 1;
}
if(strcmp(item, "mats") == 0)
{
if(amount == 0) return SendClientMessage(playerid, COLOR_GREY, "* Usuage: /car get mats [amount]");
if(amount < 0) return SendClientMessage(playerid, COLOR_GREY, "* Usuage: /car get mats [amount]");
new mats = CarInfo[car][vMats];
if(amount > mats) return SendClientMessage(playerid, COLOR_GREY, "* Your car does not have that many Materials !");
CarInfo[car][vMats] -= amount;
format(string, sizeof(string), "* %s takes out something from his vehicle.", PlayerName(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
PlayerInfo[playerid][pMats] += amount;
format(string, sizeof(string), " New amount after taking %d materials: %d", amount, CarInfo[car][vMats]);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
return 1;
}
if(strcmp(item, "weapon") == 0)
{
if(amount == 1)
{
if(CarInfo[car][vGun1] == 0) return SendClientMessage(playerid, COLOR_GREY, "* No weapon in Slot 1.");
format(string, sizeof(string), "* %s takes a weapon from their car.", PlayerName(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
new gunid = CarInfo[car][vGun1];
CarInfo[car][vGun1] = 0;
GivePlayerGun(playerid, gunid);
SendClientMessage(playerid, COLOR_LIGHTBLUE, " You taken a weapon from Slot 1.");
}
if(amount == 2)
{
if(CarInfo[car][vGun2] == 0) return SendClientMessage(playerid, COLOR_GREY, "* No weapon in Slot 2.");
format(string, sizeof(string), "* %s takes a weapon from their car.", PlayerName(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
new gunid = CarInfo[car][vGun2];
CarInfo[car][vGun2] = 0;
GivePlayerGun(playerid, gunid);
SendClientMessage(playerid, COLOR_LIGHTBLUE, " You taken a weapon from Slot 2.");
}
if(amount == 3)
{
if(CarInfo[car][vGun3] == 0) return SendClientMessage(playerid, COLOR_GREY, "* No weapon in Slot 3.");
format(string, sizeof(string), "* %s takes a weapon from their car.", PlayerName(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
new gunid = CarInfo[car][vGun3];
CarInfo[car][vGun3] = 0;
GivePlayerGun(playerid, gunid);
SendClientMessage(playerid, COLOR_LIGHTBLUE, " You taken a weapon from Slot 3.");
}
else
{
SendClientMessage(playerid, COLOR_GREY, "* Usuage: /car get weapon [1 2 or 3]");
return 1;
}
}
else return SendClientMessage(playerid, COLOR_GRAD3, "* Syntax: Get - cash pot crack mats weapon");
}
else return SendClientMessage(playerid, COLOR_GREY, "* Invalid syntax !");
return 1;
}
"... well it doesn't send that. I want it too, if action doesn't equal whatever I have put in above. Instead, it keeps sending me "SendClientMessage(playerid, COLOR_GREY, "* Usuage: /car put cash [amount]");"