29.07.2013, 19:55
Hey! I have this problem with my command. When I enter /refuel, I got message "USAGE: /refuel [choice]...." and command starts to behave that I typed already "full" so it will do that part of the code. Also it won't start timer. Something is wrong with my command but I don't know what. Can someone please help me?
Код:
CMD:refuel(playerid, params[]) { new string[128], choice[24],amount; new vehicleid = GetPlayerVehicleID(playerid); if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command."); if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You are not driving a vehicle."); if(!IsPlayerInRangeOfPoint(playerid, 15, -2620.871,2261.44,8.16) && !IsPlayerInRangeOfPoint(playerid, 15, -2032.98,161.46,29.046) && !IsPlayerInRangeOfPoint(playerid, 15, 1676.151,432.169,17.18) && !IsPlayerInRangeOfPoint(playerid, 15, -2420.154,969.84,45.3) && !IsPlayerInRangeOfPoint(playerid, 15, -1465.75,1873.35,32.63)) return SendClientMessage(playerid, COLOR_GREY, "You are not near any gas station."); if(sscanf(params,"s",choice)) { SendClientMessage(playerid, COLOR_GREY, "USAGE: /refuel [choice]"); SendClientMessage(playerid, COLOR_GREY, "Choices: FULL | LITER"); format(string,sizeof(string), "Fuel: %d/100 liters.", Fuel[vehicleid]); SendClientMessage(playerid, COLOR_WHITE, string); } if(!strcmp(choice, "full", true)) // problem starts here I think { new engine,lights,alarm,doors,bonnet,boot,objective; GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective); if(engine == 1) return SendClientMessage(playerid, COLOR_GREY, "You need to turn off your engine first."); new currentFuel; currentFuel = 100 - Fuel[vehicleid]; if(PlayerInfo[playerid][pMoney] < currentFuel*3) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to refuel your vehicle."); GiveDodMoney(playerid, -(3*currentFuel)); Fuel[vehicleid] += currentFuel; } if(!strcmp(choice, "liter", true)) { if(sscanf(params,"si",choice,amount)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /refuel liter [amount]"); new currentFuel; currentFuel = 100 - Fuel[vehicleid]; new engine,lights,alarm,doors,bonnet,boot,objective; GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective); if(engine == 1) return SendClientMessage(playerid, COLOR_GREY, "You need to turn off your engine first."); if(amount > currentFuel) return SendClientMessage(playerid, COLOR_GREY, "Your vehicle can't store that much fuel."); if(PlayerInfo[playerid][pMoney] < amount*3) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to refuel your vehicle."); GiveDodMoney(playerid, -(3*currentFuel)); Fuel[vehicleid] += amount; } format(string, sizeof(string), "%s starts to pump fuel into their vehicle.", RPN(playerid)); SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE); Refill[playerid] = 1; SetTimerEx("RefillTimer", 3000, false, "i", playerid); return 1; }