PDA

View Full Version : Refuel cmd need help !


hulitubolies
20/07/2012, 11:16 AM
stock StopRefueling(playerid)
{
GivePlayerCash(playerid, -RefuelingVehiclePrice[playerid]);
SendFormattedMessage(playerid, COLOR_WHITE,"Your vehicle's tank has been refilled for $%d.", RefuelingVehiclePrice[playerid]);

new mypoint = -1;
for (new i=0; i<MAX_POINTS; i++)
{
if(strcmp(Points[i][Name], "Fossil Fuel Company", true) == 0)
{
mypoint = i;
}
}
for(new i = 0; i < sizeof(FamilyInfo); i++)
{
if(strcmp(Points[mypoint][Owner], FamilyInfo[i][FamilyName], true) == 0)
{
FamilyInfo[i][FamilyBank] = FamilyInfo[i][FamilyBank]+(RefuelingVehiclePrice[playerid]/10);
}
}

RefuelingVehicle[playerid] = 0; RefuelingVehiclePrice[playerid] = 0; KillTimer(RefuelingVehicleTimer[playerid]);
return true;
}
Problem is that when i refuel my vehicle it repeats saying ''Your vehicle's tank has been refilled for (the money)''
Whats wrong here ?? when i restart server it stops sayin that

hulitubolies
20/07/2012, 11:22 AM
Any one know's ?

Cypress
20/07/2012, 11:34 AM
Where do you call this function? Under a timer?

jeremy8810
20/07/2012, 11:44 AM
You can try to do it with SendClientMessage but don't know if it will resolve your problem

hulitubolies
20/07/2012, 12:45 PM
Where do you call this function? Under a timer?
Yes !!!

hulitubolies
20/07/2012, 09:03 PM
Any help ??
and SendClientMessage make it worst !

Cypress
21/07/2012, 11:04 AM
Show the code of where you call this function.

Also show the timer, and where it starts acting.

hulitubolies
21/07/2012, 08:59 PM
CMD:refuel(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid,engine,lights,alarm,d oors,bonnet,boot,objective);
if(engine == VEHICLE_PARAMS_ON) return SendClientMessageEx(playerid, COLOR_RED, "You need to shut off the engine before filling up (/car engine).");
if(!IsAtFuelStation(playerid)) return SendClientMessageEx(playerid, COLOR_RED, "You're not at a fuel station.");
if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessageEx(playerid,COLOR_RED,"This vehicle doesn't need fuel.");
if(VehicleFuel[vehicleid] >= 100.0) return SendClientMessageEx(playerid, COLOR_RED, "This vehicle's tank is already full.");
if(RefuelingVehicle[playerid] == 1) return SendClientMessageEx(playerid, COLOR_RED, "You are refilling your vehicle's tank.");
SendClientMessageEx(playerid, COLOR_WHITE, "Refueling your vehicle's tank, please wait.");
RefuelingVehicle[playerid] = 1;
RefuelingVehicleTimer[playerid] = SetTimerEx("ReFill", 1000, true, "i", playerid);
}
return 1;
}

else if(strcmp(params,"refill",true) == 0) {
if(RefillOffer[playerid] < 999) {
if(GetPlayerCash(playerid) > RefillPrice[playerid]) {
if(IsPlayerInAnyVehicle(playerid)) {
if(IsPlayerConnected(RefillOffer[playerid])) {
new Float:fueltogive;
new level = PlayerInfo[RefillOffer[playerid]][pMechSkill];
if(level >= 0 && level < 50) { fueltogive = 10.0; }
else if(level >= 50 && level < 100) { fueltogive = 20.0; }
else if(level >= 100 && level < 200) { fueltogive = 30.0; }
else if(level >= 200 && level < 400) { fueltogive = 40.0; }
else if(level >= 400) { fueltogive = 50.0; }
GetPlayerName(RefillOffer[playerid], giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
new vehicleid = GetPlayerVehicleID(playerid);
VehicleFuel[vehicleid] = floatadd(VehicleFuel[vehicleid], fueltogive);
if(VehicleFuel[vehicleid] > 100.0) VehicleFuel[vehicleid] = 100.0;
GivePlayerCash(RefillOffer[playerid], RefillPrice[playerid]);
GivePlayerCash(playerid, -RefillPrice[playerid]);
new ip[32], ipex[32];
GetPlayerIp(playerid, ip, sizeof(ip));
GetPlayerIp(RefillOffer[playerid], ipex, sizeof(ipex));
format(string, sizeof(string), "%s(IP:%s) has refilled the vehicle from %s(IP:%s) for $%d", GetPlayerNameEx(playerid), ip, GetPlayerNameEx(RefillOffer[playerid]), ipex, RefillPrice[playerid]);
Log("logs/pay.log", string);
format(string, sizeof(string), "* %s has refilled %s's vehicle.", giveplayer, GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
format(string, sizeof(string), "* You have added %.2f fuel to your car for $%d by Car Mechanic %s.",fueltogive,RefillPrice[playerid],giveplayer);
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* You added %.2f fuel to %s's car, the $%d has been added to your money on hand!",fueltogive,sendername,RefillPrice[playerid]);
SendClientMessageEx(RefillOffer[playerid], COLOR_LIGHTBLUE, string);
PlayerInfo[RefillOffer[playerid]][pMechSkill] ++;

RefillWarn[playerid][RefillOffer[playerid]] += RefillPrice[playerid];
if(RefillWarn[playerid][RefillOffer[playerid]] >= 30000 && (PlayerInfo[playerid][pLevel] <= 3 || PlayerInfo[RefillOffer[playerid]][pLevel] <= 3)) {
format(string, sizeof(string), "%s (IP:%s) has refueled %s (IP:%s) $%d in this session.", GetPlayerNameEx(playerid), ip, GetPlayerNameEx(RefillOffer[playerid]), ipex, RefillWarn[playerid][RefillOffer[playerid]]);
Log("logs/pay.log", string);
ABroadCast(COLOR_YELLOW, string, 2);
}

RefillOffer[playerid] = 999;
RefillPrice[playerid] = 0;
return 1;
}
return 1;
}
return 1;
}
else {
SendClientMessageEx(playerid, COLOR_GREY, " You can't afford the refill!");
return 1;
}
}
else {
SendClientMessageEx(playerid, COLOR_GREY, " No-one offered you to refill your Car!");
return 1;
}

I guess yu need this ??

Youice
21/07/2012, 09:22 PM
just show us the code of "SendFormattedMessage", it may be the problem

Dare Devil.....
21/07/2012, 09:54 PM
Try this out

CMD:refuel(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid,engine,lights,alarm,d oors,bonnet,boot,objective);
if(engine == VEHICLE_PARAMS_ON) return SendClientMessageEx(playerid, COLOR_RED, "You need to shut off the engine before filling up (/car engine).");
if(!IsAtFuelStation(playerid)) return SendClientMessageEx(playerid, COLOR_RED, "You're not at a fuel station.");
if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessageEx(playerid,COLOR_RED,"This vehicle doesn't need fuel.");
if(VehicleFuel[vehicleid] >= 100.0) return SendClientMessageEx(playerid, COLOR_RED, "This vehicle's tank is already full.");
if(RefuelingVehicle[playerid] == 1) return SendClientMessageEx(playerid, COLOR_RED, "You are refilling your vehicle's tank.");
SendClientMessageEx(playerid, COLOR_WHITE, "Refueling your vehicle's tank, please wait.");
RefuelingVehicle[playerid] = 1;
RefuelingVehicleTimer[playerid] = SetTimerEx("ReFill", 1000, true, "i", playerid);
}
return 1;
}


forward ReFill(playerid);
public ReFill(playerid)
{
if(!IsAtFuelStation(playerid) || !IsPlayerInAnyVehicle(playerid) || VehicleFuel[GetPlayerVehicleID(playerid)] >= 100.0 || GetPlayerCash(playerid) < 1)
{
StopRefueling(playerid);
}
else
{
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid),en gine,lights,alarm,doors,bonnet,boot,objective);
if(engine == VEHICLE_PARAMS_ON) return StopRefueling(playerid);
VehicleFuel[GetPlayerVehicleID(playerid)] += 1.0; RefuelingVehiclePrice[playerid] += 30;
if(VehicleFuel[GetPlayerVehicleID(playerid)] >= 100.0) VehicleFuel[GetPlayerVehicleID(playerid)] = 100.0;
}
return true;
}


stock StopRefueling(playerid)
{
GivePlayerCash(playerid, -100);
SendFormattedMessage(playerid, COLOR_WHITE,"Your vehicle's tank has been refilled for $100.");

new mypoint = -1;
for (new i=0; i<MAX_POINTS; i++)
{
if(strcmp(Points[i][Name], "Fossil Fuel Company", true) == 0)
{
mypoint = i;
}
}
for(new i = 0; i < sizeof(FamilyInfo); i++)
{
if(strcmp(Points[mypoint][Owner], FamilyInfo[i][FamilyName], true) == 0)
{
FamilyInfo[i][FamilyBank] = FamilyInfo[i][FamilyBank]+(RefuelingVehiclePrice[playerid]/10);
}
}

RefuelingVehicle[playerid] = 0; RefuelingVehiclePrice[playerid] = 0; KillTimer(RefuelingVehicleTimer[playerid] = 6000);
return true;
}