SA-MP Forums Archive
command, and something else :P - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: command, and something else :P (/showthread.php?tid=237701)



command, and something else :P - iGetty - 10.03.2011

I was wondering, how could I get it so when a car runs out of fuel, the engine stops, and can't be started?

And also, how do I get it so when I type a command, it takes $20 off you?

Here's the command:

pawn Код:
if (strcmp("/refuel", cmdtext, true, 10) == 0)
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                new vehicleid = GetPlayerVehicleID(playerid);
                Carinfo[vehicleid][Fuel] = 100;
                SendClientMessage(playerid, COLOR_GREEN, "Your tank has been filled.");
            }
            else return SendClientMessage(playerid, COLOR_YELLOW, "You have to be inside a vehicle to refuel!");
        }
        return 1;
}



Re: command, and something else :P - Roomeo - 10.03.2011

pawn Код:
if (strcmp("/refuel", cmdtext, true, 7) == 0)
         {
             if (IsPlayerInAnyVehicle(playerid))
             if (GetPlayerMoney(playerid) < 20) return SendClientMessage(playerid, COLOR_RED, " You dont have enough money!");
            {
                    new vehicleid = GetPlayerVehicleID(playerid);
                    Carinfo[vehicleid][Fuel] = 100;
                  SendClientMessage(playerid, COLOR_YELLOW, "Your Tank Has Been Filled.");
            }                
            else return SendClientMessage(playerid, COLOR_YELLOW, "You have to be inside a vehicle to refuel!");
        }
        return 1;
}
Not tested


Re: command, and something else :P - Cameltoe - 10.03.2011

Quote:
Originally Posted by Roomeo
Посмотреть сообщение
pawn Код:
if (strcmp("/refuel", cmdtext, true, 7) == 0)
         {
             if (IsPlayerInAnyVehicle(playerid))
             if (GetPlayerMoney(playerid) < 20) return SendClientMessage(playerid, COLOR_RED, " You dont have enough money!");
            {
                    new vehicleid = GetPlayerVehicleID(playerid);
                    Carinfo[vehicleid][Fuel] = 100;
                  SendClientMessage(playerid, COLOR_YELLOW, "Your Tank Has Been Filled.");
            }                
            else return SendClientMessage(playerid, COLOR_YELLOW, "You have to be inside a vehicle to refuel!");
        }
        return 1;
}
Not tested
pawn Код:
command(refuel, playerid, params[])
{
     if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_YELLOW, "You have to be inside a vehicle to refuel!");
     if (GetPlayerMoney(playerid) < 20) return SendClientMessage(playerid, COLOR_RED, " You dont have enough money!");
     Carinfo[GetPlayerVehicleID(playerid)][Fuel] = 100;
     GivePlayerMoney(playerid, -20);
     SendClientMessage(playerid, COLOR_YELLOW, "Your Tank Has Been Filled for $ 20.");
     return 1;
}



Re: command, and something else :P - iGetty - 10.03.2011

Okay, thanks


Re: command, and something else :P - Haydz - 10.03.2011

Quote:
Originally Posted by Roomeo
Посмотреть сообщение
pawn Код:
if (strcmp("/refuel", cmdtext, true, 7) == 0)
         {
             if (IsPlayerInAnyVehicle(playerid))
             if (GetPlayerMoney(playerid) < 20) return SendClientMessage(playerid, COLOR_RED, " You dont have enough money!");
            {
                    new vehicleid = GetPlayerVehicleID(playerid);
                    Carinfo[vehicleid][Fuel] = 100;
                  SendClientMessage(playerid, COLOR_YELLOW, "Your Tank Has Been Filled.");
            }                
            else return SendClientMessage(playerid, COLOR_YELLOW, "You have to be inside a vehicle to refuel!");
        }
        return 1;
}
Not tested
EDIT: nvm.


Re: command, and something else :P - Roomeo - 10.03.2011

i just maded it in fast and Quick Reply


Re: command, and something else :P - iGetty - 10.03.2011

Quote:
Originally Posted by Cameltoe
Посмотреть сообщение
pawn Код:
command(refuel, playerid, params[])
{
     if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_YELLOW, "You have to be inside a vehicle to refuel!");
     if (GetPlayerMoney(playerid) < 20) return SendClientMessage(playerid, COLOR_RED, " You dont have enough money!");
     Carinfo[GetPlayerVehicleID(playerid)][Fuel] = 100;
     GivePlayerMoney(playerid, -20);
     SendClientMessage(playerid, COLOR_YELLOW, "Your Tank Has Been Filled for $ 20.");
     return 1;
}
Okay so I try it, but it doesn't take $20?

Thanks.