SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 20/07/2012, 11:16 AM   #1
hulitubolies
Big Clucker
 
Join Date: Jun 2012
Posts: 55
Reputation: 0
Default Refuel cmd need help !

pawn Code:
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 is offline   Reply With Quote
Old 20/07/2012, 11:22 AM   #2
hulitubolies
Big Clucker
 
Join Date: Jun 2012
Posts: 55
Reputation: 0
Default Re: Refuel cmd need help !

Any one know's ?
hulitubolies is offline   Reply With Quote
Old 20/07/2012, 11:34 AM   #3
Cypress
Gangsta
 
Cypress's Avatar
 
Join Date: Dec 2009
Location: Germany
Posts: 937
Reputation: 127
Default Re: Refuel cmd need help !

Where do you call this function? Under a timer?
__________________

Welcome stranger. I like your attitude.
Cypress is offline   Reply With Quote
Old 20/07/2012, 11:44 AM   #4
jeremy8810
Big Clucker
 
Join Date: Feb 2012
Location: Your screen[NL]
Posts: 193
Reputation: 17
Default Re: Refuel cmd need help !

You can try to do it with SendClientMessage but don't know if it will resolve your problem
__________________
Did I helped you? +rep would be nice
[MAP] Los Santos Roadwork
[MAP] Truckstop/Restaurant/Bar
jeremy8810 is offline   Reply With Quote
Old 20/07/2012, 12:45 PM   #5
hulitubolies
Big Clucker
 
Join Date: Jun 2012
Posts: 55
Reputation: 0
Default Re: Refuel cmd need help !

Where do you call this function? Under a timer?
Yes !!!
hulitubolies is offline   Reply With Quote
Old 20/07/2012, 09:03 PM   #6
hulitubolies
Big Clucker
 
Join Date: Jun 2012
Posts: 55
Reputation: 0
Default Re: Refuel cmd need help !

Any help ??
and SendClientMessage make it worst !
hulitubolies is offline   Reply With Quote
Old 21/07/2012, 11:04 AM   #7
Cypress
Gangsta
 
Cypress's Avatar
 
Join Date: Dec 2009
Location: Germany
Posts: 937
Reputation: 127
Default Re: Refuel cmd need help !

Show the code of where you call this function.

Also show the timer, and where it starts acting.
__________________

Welcome stranger. I like your attitude.
Cypress is offline   Reply With Quote
Old 21/07/2012, 08:59 PM   #8
hulitubolies
Big Clucker
 
Join Date: Jun 2012
Posts: 55
Reputation: 0
Default Re: Refuel cmd need help !

pawn Code:
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,doors,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;
}

pawn Code:
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_PURPLE,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 ??
hulitubolies is offline   Reply With Quote
Old 21/07/2012, 09:22 PM   #9
Youice
Huge Clucker
 
Youice's Avatar
 
Join Date: Jan 2012
Location: Earth Reputation:9999
Posts: 407
Reputation: 40
Default Re: Refuel cmd need help !

just show us the code of "SendFormattedMessage", it may be the problem
Youice is offline   Reply With Quote
Old 21/07/2012, 09:54 PM   #10
Dare Devil.....
Huge Clucker
 
Dare Devil.....'s Avatar
 
Join Date: Jan 2012
Location: Pakistan
Posts: 253
Reputation: 10
Default Re: Refuel cmd need help !

Try this out
pawn Code:
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,doors,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;
}

pawn Code:
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),engine,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;
}

pawn Code:
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;
}
Dare Devil..... is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
/refuel BigD Scripting Help 2 29/03/2012 03:53 PM
Refuel help! WG Chinn Help Archive 2 07/08/2011 11:08 PM
Bug with refuel need help. GBLTeam Help Archive 10 26/07/2011 01:03 AM
help /refuel gondes Help Archive 2 13/01/2011 08:04 AM
help /refuel gondes Help Archive 8 25/09/2010 08:23 AM


All times are GMT. The time now is 06:23 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.