rendered paste body#include <a_samp>
#include <xgas>
new Filling[MAX_PLAYERS];
new Float:Station[16][3] = {
{2109.2126,917.5845,10.8203},
{2640.1831,1103.9224,10.8203},
{611.8934,1694.7921,6.7193},
{-1327.5398,2682.9771,49.7896},
{-2413.7427,975.9317,45.0031},
{-1672.3597,414.2950,6.8866},
{-2244.1365,-2560.6294,31.6276},
{-1603.0166,-2709.3589,48.2419},
{1939.3275,-1767.6813,13.2787},
{-94.7651,-1174.8079,1.9979},
{1381.6699,462.6467,19.8540},
{657.8167,-559.6507,16.0630},
{-1478.2916,1862.8318,32.3617},
{2147.3054,2744.9377,10.5263},
{2204.9602,2480.3494,10.5278},
{1590.9493,2202.2637,10.5247}
};
main()
{
print("\n----------------------------------");
print(" xGas_Example Script by Pixels^");
print("----------------------------------\n");
}
public OnGameModeInit()
{
SetGameModeText("xGas_Example");
xGas_SetAllGas(100);
xGas_SetAllEngineOil(100);
SetTimer("Fuel",1000,1);
SetTimer("Check",2000,1);
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1954.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
return 1;
}
public OnPlayerDisconnect(playerid)
{
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid)
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new string[76];
new v = GetPlayerVehicleID(playerid);
if(strcmp(cmdtext, "/showgas", true) == 0) {
format(string,sizeof(string),"%d",xGas_ShowGas(v));
SendClientMessage(playerid,0xFFFFFFAA,string);
return 1;
}
if(strcmp(cmdtext, "/refuel", true) == 0) {
if(!IsPlayerInAnyVehicle(playerid)) {
SendClientMessage(playerid,0xFF0000AA,"Not in any vehicle");
return 1;
}
if(GetPlayerMoney(playerid) <= 99 && GetPlayerMoney(playerid) >= 1) {
SendClientMessage(playerid,0xFF0000AA,"Not enough money to refuel");
return 1;
}
Filling[playerid] = 1;
GivePlayerMoney(playerid,-100);
SendClientMessage(playerid,0xFFFFFFAA,"Filling vehicle");
return 1;
}
if(strcmp(cmdtext, "/repair", true) == 0) {
if(!IsPlayerInAnyVehicle(playerid)) {
SendClientMessage(playerid,0xFF0000AA,"Not in any vehicle");
return 1;
}
if(GetPlayerMoney(playerid) <= 99 && GetPlayerMoney(playerid) >= 1) {
SendClientMessage(playerid,0xFF0000AA,"Not enough money to refuel");
return 1;
}
if(xGas_GetEngineOil(v) >= 85) {
SendClientMessage(playerid,0xFF0000AA,"Your engine oil is in a good state");
return 1;
}
Filling[playerid] = 2;
GivePlayerMoney(playerid,-100);
SendClientMessage(playerid,0xFFFFFFAA,"Repairing vehicle");
return 1;
}
return 0;
}
public OnPlayerInfoChange(playerid)
{
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public Fuel() {
for(new i=0; i<MAX_PLAYERS; i++) {
if(GetPlayerState(i) == 2) {
new v = GetPlayerVehicleID(i);
new string[76];
if(Filling[i] == 1) {
if(xGas_GetGas(v) >= 100) {
SendClientMessage(i,0xFF0000AA,"Vehicle refueled");
return Filling[i] = 0;
}
xGas_Fuel(v);
format(string,sizeof(string),"~n~~n~~n~~n~~n~~n~~w~Fuel %d~n~EngineOil %d",xGas_GetGas(v),xGas_GetEngineOil(v));
return GameTextForPlayer(i,string,2000,1);
}
if(Filling[i] == 2) {
if(xGas_GetEngineOil(v) >= 100) {
SendClientMessage(i,0xFF0000AA,"Vehicle repaired");
return Filling[i] = 0;
}
xGas_EngineOil(v,true,10);
format(string,sizeof(string),"~n~~n~~n~~n~~n~~n~~w~Fuel %d~n~EngineOil %d",xGas_GetGas(v),xGas_GetEngineOil(v));
return GameTextForPlayer(i,string,2000,1);
}
if(xGas_GetGas(v) <= 0) {
TogglePlayerControllable(i,0);
return SendClientMessage(i,0xFF0000AA,"You have ran out of fuel");
}
if(xGas_GetEngineOil(v) <= 0) {
TogglePlayerControllable(i,0);
return SendClientMessage(i,0xFF0000AA,"Your engine oil just damaged your engine");
}
xGas_Deplete(v);
xGas_EngineOil(v,false,1); // usage of engine oil
format(string,sizeof(string),"~n~~n~~n~~n~~n~~n~~w~Fuel %d~n~EngineOil %d",xGas_GetGas(v),xGas_GetEngineOil(v));
return GameTextForPlayer(i,string,2000,1);
}
}
return 1;
}
public Check() {
for(new i=0; i<MAX_PLAYERS; i++) {
for(new c=0; c<16; c++) {
if(PlayerToPoint(i,13,Station[c][0],Station[c][1],Station[c][1])) {
GameTextForPlayer(i,"~w~/refuel for gas~n~~y~/repair for engine oil",1000,1);
return 1;
}
}
}
return 1;
}
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tmpposx, Float:tmpposy, Float:tmpposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
tmpposx = (oldposx -x);
tmpposy = (oldposy -y);
tmpposz = (oldposz -z);
if (((tmpposx < radi) && (tmpposx > -radi)) && ((tmpposy < radi) && (tmpposy > -radi)) && ((tmpposz < radi) && (tmpposz > -radi)))
{
return 1;
}
return 0;
}