Szerző Téma: Benzin  (Megtekintve 574 alkalommal)

Nem elérhető Stramm

  • 193
    • Profil megtekintése
Benzin
« Dátum: 2013. június 17. - 14:17:54 »
0 Show voters
Üdv Valaki készítene egy olyat hogy a kocsiból fodjon a benzin és ha kifogyott akkor a /benzin parancsalújra teli legyen.

Nem elérhető ROOCK

  • 183
    • Profil megtekintése
Benzin
« Válasz #1 Dátum: 2013. június 18. - 08:23:40 »
+1 Show voters
tess ez zcmd vel van megoldva ha beirod hogy benzin [liter] akkor feltankolja a kocsit és leveszi a pénzt is
annyiba kerül amennyit tankol annak a 2x ese
 

#include <a_samp>
#include <zcmd>
#define COLOR_GREY             0xAFAFAFAA
#define COLOR_GREEN          0x33FF33AA
#define COLOR_YELLOW          0xFFFF00AA
#define COLOR_WHITE          0xFFFFFFAA
#define COLOR_BRIGHTRED       0xE60000FF
#define COLOR_BLUE             0x0000FFAA
#define COLOR_PURPLE          0x9900FFAA
#define COLOR_BROWN          0x993300AA
#define COLOR_ORANGE          0xFF9933AA
#define COLOR_CYAN             0x99FFFFAA
#define COLOR_TAN             0xFFFFCCAA
#define COLOR_PINK             0xFF66FFAA
#define COLOR_KHAKI          0x999900AA
#define COLOR_LIME             0x99FF00AA
#define COLOR_BLACK          0x000000AA
#define COLOR_TURQ             0x00A3C0AA
#define COLOR_LIGHTBLUE       0x33CCFFAA
#define COLOR_DARKRED          0xAA993333
#define COLOR_VIOLET          0x9955DEEE
#define COLOR_RED             0xFB0000FF
#define DIVBY                   1.300
new
Benzin[MAX_VEHICLES],
bool:PortableFuel[MAX_PLAYERS],
FuelTimer;
new
Text: Fuel[MAX_PLAYERS],
Text: BlackBox,
Text: Moving[MAX_PLAYERS];
 
public OnFilterScriptInit()
{
FuelTimer = SetTimer(\"SubFuel\", 12000, true);
print(\"----------------------------------\");
print(\" Fuel System by RyDeR Edited by Németh Martin(Fanatik) - Betöltve - \");
print(\"----------------------------------\");
BlackBox = TextDrawCreate(354.000000, 422.000000, \"_\");
TextDrawBackgroundColor(BlackBox, 255);
TextDrawFont(BlackBox, 1);
TextDrawLetterSize(BlackBox, 0.509999, 1.000000);
TextDrawColor(BlackBox, -1);
TextDrawSetOutline(BlackBox, 0);
TextDrawSetProportional(BlackBox, 1);
TextDrawSetShadow(BlackBox, 1);
TextDrawUseBox(BlackBox, 1);
TextDrawBoxColor(BlackBox, 0xFF80001A);
TextDrawTextSize(BlackBox, 277.000000, 51.000000);
new
    i;
while (i != GetMaxPlayers())
{
Fuel = TextDrawCreate(258.000000, 421.000000, \" \");
TextDrawBackgroundColor(Fuel, 255);
TextDrawFont(Fuel, 1);
TextDrawLetterSize(Fuel, 0.250000, 1.100000);
TextDrawColor(Fuel, -1);
TextDrawSetOutline(Fuel, 0);
TextDrawSetProportional(Fuel, 1);
TextDrawSetShadow(Fuel, 1);
Moving = TextDrawCreate(354.000000, 422.000000, \"_\");
TextDrawBackgroundColor(Moving, 255);
TextDrawFont(Moving, 1);
TextDrawLetterSize(Moving, 0.509999, 1.000000);
TextDrawColor(Moving, -1);
TextDrawSetOutline(Moving, 0);
TextDrawSetProportional(Moving, 1);
TextDrawSetShadow(Moving, 1);
TextDrawUseBox(Moving, 1);
TextDrawBoxColor(Moving, 0xFF8000C1);
TextDrawTextSize(Moving, 277.000000, 51.000000);
++i;
}
new
v;
while (v != MAX_VEHICLES)
{
    Benzin[v] = random(100);
++v;
}
return 1;
}
public OnFilterScriptExit()
{
new
i,
v;
while (i != GetMaxPlayers())
{
      TextDrawDestroy(Fuel);
      TextDrawDestroy(Moving);
++i;
}
TextDrawDestroy(BlackBox);
KillTimer(FuelTimer);
while (v != MAX_VEHICLES)
{
    Benzin[v] = 100;
++v;
}
return 1;
}
forward SubFuel();
public SubFuel()
{
new
    i;
while (i != GetMaxPlayers())
{
    if (IsPlayerInAnyVehicle(i))
    {
    new string[128];
            if(Benzin[GetPlayerVehicleID(i)] <0) Benzin[GetPlayerVehicleID(i)] = 0;
    if(IsPlayerInAnyVehicle(i))
    {
        Benzin[GetPlayerVehicleID(i)]-=1;
        format(string, 128, \"Benzin:       %%%d\", Benzin[GetPlayerVehicleID(i)]);
        TextDrawSetString(Fuel, string), TextDrawShowForPlayer(i, Fuel),
         TextDrawShowForPlayer(i, BlackBox),
            TextDrawTextSize(Moving, (354.0 - (Benzin[GetPlayerVehicleID(i)] / DIVBY)), 0.000000),
               TextDrawShowForPlayer(i, Moving);
    }
    if (Benzin[GetPlayerVehicleID(i)] < 1)
   {
      Benzin[GetPlayerVehicleID(i)] = 0;
       GameTextForPlayer(i, \"~n~~n~~n~~n~~n~~n~~n~~w~Nincs üzemanyag a jármûvedben.\", 4000, 3);
       TogglePlayerControllable(i, false);
       RemovePlayerFromVehicle(i);
   }
}
else
        {
            TextDrawHideForPlayer(i, Fuel),
           TextDrawHideForPlayer(i, BlackBox),
           TextDrawHideForPlayer(i, Moving);
            GameTextForPlayer(i, \" \", 100, 3);
            TogglePlayerControllable(i, true);
}
++i;
}
return 1;
}
public OnVehicleSpawn(vehicleid)
{
Benzin[vehicleid] = random(100);
}
public OnPlayerConnect(playerid)
{
PortableFuel[playerid] = false;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
TextDrawHideForPlayer(playerid, Fuel[playerid]);
TextDrawHideForPlayer(playerid, Moving[playerid]);
TextDrawHideForPlayer(playerid, BlackBox);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
TextDrawHideForPlayer(playerid, Fuel[playerid]);
TextDrawHideForPlayer(playerid, Moving[playerid]);
TextDrawHideForPlayer(playerid, BlackBox);
return 1;
}
CMD:benzin(playerid, params[]){
new
miktar,
string[128],
string2[128],
string3[128],
string4[128],
Fiyat,
Sum;
if (!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, \">> Nem vagy a jármûben!\");
if (!IsAtGasStation(playerid)) return SendClientMessage(playerid, COLOR_RED, \">> Nem vagy a kocsiban!\");
if (!strlen(params)) return SendClientMessage(playerid, COLOR_RED, \">> /benzin [amount in 0 - 100 l]\");
miktar = strval(params);
if (miktar < 1 || miktar > 100) return SendClientMessage(playerid, COLOR_RED, \">> Rossz literszám! (0-100l)\");
if (Benzin[GetPlayerVehicleID(playerid)] >= 100) return SendClientMessage(playerid, COLOR_RED, \">> Nem tudsz tankolni a tank tele van!\");
Fiyat = (miktar * 2);
format(string2, 128, \">> Nincs elég pénzed! Neked még kell $%d.\", Fiyat);
if (GetPlayerMoney(playerid) < Fiyat) return SendClientMessage(playerid, COLOR_RED, string2);
GivePlayerMoney(playerid, -Fiyat);
format(string, 128, \">> Te tankoltál a jármûvedbe %d liter üzemanyagot. Ára: $%d.\", miktar, Fiyat);
SendClientMessage(playerid, COLOR_LIME, string);
Benzin[GetPlayerVehicleID(playerid)] += miktar;
if (Benzin[GetPlayerVehicleID(playerid)] > 100) Sum = miktar*2-Benzin[GetPlayerVehicleID(playerid)]+100, GivePlayerMoney(playerid, Sum), format(string4, 128, \">> You have choose a too large amount of liters that your car can\'t accept. Here\'s your change($%d).\", Sum), SendClientMessage(playerid, COLOR_ORANGE, string4), Benzin[GetPlayerVehicleID(playerid)] = 100;
format(string3, 128, \"Benzin:       %%%d\", Benzin[GetPlayerVehicleID(playerid)]);
TextDrawSetString(Fuel[playerid], string3),
TextDrawShowForPlayer(playerid, Fuel[playerid]),
   TextDrawTextSize(Moving[playerid], (354.0 - (Benzin[GetPlayerVehicleID(playerid)] / DIVBY)), 0.000000),
      TextDrawShowForPlayer(playerid, Moving[playerid]);
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
new
    string[128],
string2[128];
 
if(newstate == PLAYER_STATE_DRIVER)
{
   format(string, 128, \"Benzin:       %%%d\", Benzin[GetPlayerVehicleID(playerid)]);
         TextDrawSetString(Fuel[playerid], string),
         TextDrawShowForPlayer(playerid, Fuel[playerid]),
         TextDrawShowForPlayer(playerid, BlackBox),
            TextDrawTextSize(Moving[playerid], (354.0 - (Benzin[GetPlayerVehicleID(playerid)] / DIVBY)), 0.000000),
            TextDrawShowForPlayer(playerid, Moving[playerid]);
    if (Benzin[GetPlayerVehicleID(playerid)] < 1)
{
   Benzin[GetPlayerVehicleID(playerid)] = 1;
   format(string2, 128, \"Benzin:       %%%d\", Benzin[GetPlayerVehicleID(playerid)]);
   TextDrawSetString(Fuel[playerid], string2),
      TextDrawShowForPlayer(playerid, Fuel[playerid]),
         TextDrawTextSize(Moving[playerid], (354.0 - (Benzin[GetPlayerVehicleID(playerid)] / DIVBY)), 0.000000),
            TextDrawShowForPlayer(playerid, Moving[playerid]);
}
if(Benzin[GetPlayerVehicleID(playerid)]  < 1)
{
    Benzin[GetPlayerVehicleID(playerid)] = 0;
           GameTextForPlayer(playerid, \"~n~~n~~n~~n~~n~~n~~n~~w~Nincs elég benzin a jármûben.\", 4000, 3);
       RemovePlayerFromVehicle(playerid);
}
}
else if (newstate == PLAYER_STATE_ONFOOT)
{
    TextDrawHideForPlayer(playerid, Fuel[playerid]),
   TextDrawHideForPlayer(playerid, BlackBox),
             TextDrawHideForPlayer(playerid, Moving[playerid]);
    TogglePlayerControllable(playerid, true);
}
return 1;
}
stock IsAtGasStation(playerid)
{
    if(IsPlayerConnected(playerid))
{
if(IsPlayerInRangeOfPoint(playerid, 6.0,1004.0070,-939.3102,42.1797) || IsPlayerInRangeOfPoint(playerid, 6.0,1944.3260,-1772.9254,13.3906))
{
    return 1;
}
else if(IsPlayerInRangeOfPoint(playerid, 6.0,-90.5515,-1169.4578,2.4079) || IsPlayerInRangeOfPoint(playerid, 6.0,-1609.7958,-2718.2048,48.5391))
{
    return 1;
}
else if(IsPlayerInRangeOfPoint(playerid, 6.0,-2029.4968,156.4366,28.9498) || IsPlayerInRangeOfPoint(playerid, 8.0,-2408.7590,976.0934,45.4175))
{
    return 1;
}
else if(IsPlayerInRangeOfPoint(playerid, 5.0, -2243.9629,-2560.6477,31.8841) || IsPlayerInRangeOfPoint(playerid, 8.0,-1676.6323,414.0262,6.9484))
{
    return 1;
}
else if(IsPlayerInRangeOfPoint(playerid, 6.0,2202.2349,2474.3494,10.5258) || IsPlayerInRangeOfPoint(playerid, 10.0, 614.9333,1689.7418,6.6968))
{
    return 1;
}
else if(IsPlayerInRangeOfPoint(playerid, 8.0,-1328.8250,2677.2173,49.7665) || IsPlayerInRangeOfPoint(playerid, 6.0,70.3882,1218.6783,18.5165))
{
    return 1;
}
else if(IsPlayerInRangeOfPoint(playerid, 8.0,2113.7390,920.1079,10.5255) || IsPlayerInRangeOfPoint(playerid, 6.0,-1327.7218,2678.8723,50.0625))
{
    return 1;
}
else if(IsPlayerInRangeOfPoint(playerid, 12.0,1596.2595,2199.3120,10.8203))
{
    return 1;
}
}
return 0;
}

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal