#define VERLUST 10000 // Die Zeit, die der Motor braucht um 1 Liter zu verbrennen in Millisekunden (Hier 10 Sekunden)
#define BENZINPREIS 3 // Der Preis, den das Benzin pro Liter kostet (Hier 3$)
new Text:Anzeige[MAX_PLAYERS];
forward BenzinVerlust(); // Wir forwarden unseren Timer für den Benzinverlust
forward Auftanken(playerid); // Wir forwarden unseren Timer für das Tanken
new Tank[MAX_VEHICLES], bool:TanktGerade[MAX_VEHICLES]=false, tanktimer[MAX_PLAYERS];
new engine,lights,alarm,doors,bonnet,boot,objective; // Dies sind die Variablen die für das einschalten des Motors benötigt werden.
new bool:Motor[MAX_VEHICLES]=false; // Dies ist die Boolean für den Motor. [MAX_VEHICLES] ist angehängt, da sie für jedes Fahrzeug unterschiedlich sein kann.
#include <a_samp>
#include <ocmd>
#if defined FILTERSCRIPT
if(strcmp(cmdtext, "/m", true) == 0)
{
if(GetPlayerVehicleSeat(playerid) == 0)
{
new car = GetPlayerVehicleID(playerid);
if(GetVehicleModel(car) == 509 GetVehicleModel(car) == 481 GetVehicleModel(car) == 510)
{
SendClientMessage(playerid, COLOR_RED, "Du sitzt auf einem Fahrrad. Das hat keinen Motor!");
}
else if (Tank[car] < 1)
{
SendClientMessage(playerid, COLOR_RED, "Der Tank ist leer. Du musst erst /tanken.");
}
else if (Motor[car] == false )
{
GetVehicleParamsEx(car,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(car,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
Motor[car] = true; // Setzt den Bool Motor auf true
}
else
{
GetVehicleParamsEx(car,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(car,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
Motor[car] = false; // Setzt den Bool wieder auf falsch zurück.
}
}
return 1;
}
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#else
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
#endif
public OnGameModeInit()
{
SetTimer("BenzinVerlust", VERLUST, true);
for (new i=0; i< MAX_VEHICLES; i++)
{
GetVehicleParamsEx(i,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(i,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
Motor[i] = false;
Tank[i] = 100;
}
ManualVehicleEngineAndLights(); // Dies muss in OnGameModeInit angegeben werden, damit das ganze System überhaupt funktioniert.
for (new i=0; i< MAX_VEHICLES; i++)
{
GetVehicleParamsEx(i,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(i,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
Motor[i] = false;
}
public OnVehicleSpawn(vehicleid)
{
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
Motor[vehicleid] = false;
return 1;
}
// Don't use these lines if it's a filterscript
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerConnect(playerid)
{
Anzeige[playerid] = TextDrawCreate(630.0,410.0," "); // Erstellt das TextDraw an X|Y-Position 630|410 (unten rechts)
TextDrawSetOutline(Anzeige[playerid], 1); // Setzt dem TextDraw Outlines
TextDrawAlignment(Anzeige[playerid], 3); // Macht das TextDraw rechtsbündig
TextDrawSetShadow(Anzeige[playerid], 0); // Schaltet den Schatten des TextDraws aus
TextDrawShowForPlayer(playerid,Anzeige[playerid]); // Zeigt das TextDraw dem Spieler
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
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, text[])
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/tanken", true) == 0)
{
else if (GetPlayerVehicleSeat(playerid) != 0) return SendClientMessage(playerid,COLOR_RED,"Du bist in keinem Fahrzeug (oder kein Fahrer).");
new car = GetPlayerVehicleID(playerid);
else if (TanktGerade[car]) return SendClientMessage(playerid,COLOR_RED,"Du tankst schon!");
else if (Motor[car] == true) return SendClientMessage(playerid,COLOR_RED,"Du musst vor dem Tanken den Motor ausschalten.");
new ZuTanken = 100-Tank[car];
new preis = ZuTanken * BENZINPREIS;
if (GetPlayerMoney(playerid)-preis < 0) return SendClientMessage(playerid,COLOR_TOMATO,"Du hast nicht genug Geld!");
GivePlayerMoney(playerid, -preis);
SendClientMessage(playerid, COLOR_GREEN, "Tanken wird gestartet.");
SetCameraBehindPlayer(playerid);
TogglePlayerControllable(playerid,0);
public BenzinVerlust()
{
for(new i=0; i<MAX_VEHICLES; i++)
{
if (Motor[i] == true)
{
Tank[i] = Tank[i]-1;
if (Tank[i]<1)
{
Tank[i] = 0;
GetVehicleParamsEx(i,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(i,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
Motor[i] = false;
}
}
}
return 1;
}
public Auftanken(playerid)
{
new car = GetPlayerVehicleID(playerid);
Tank[car] = Tank[car] +1;
if(Tank[car] >= 100)
{
TanktGerade[car] = false;
Tank[car] = 100;
SendClientMessage(playerid, COLOR_GREEN, "Dein Fahrzeug wurde vollgetankt.");
TogglePlayerControllable(playerid,1);
KillTimer(tanktimer[playerid]);
}
return 1;
}
TanktGerade[car] = true;
tanktimer[playerid] = SetTimerEx("Auftanken",500,true,"i",playerid);
return 1;
}
if(strcmp(cmdtext, "/m", true) == 0)
{
if(GetPlayerVehicleSeat(playerid) == 0) // Überprüft zuerst ob der Spieler der Fahrer eines Fahrzeugs ist.
{
new car = GetPlayerVehicleID(playerid); // Erstellt die Variable car, die die FahrzeugID des Spielers trägt.
if(GetVehicleModel(car) == 509 GetVehicleModel(car) == 481 GetVehicleModel(car) == 510) // Wenn das Fahrzeug ein Fahrrad ist,
{ // dann sende dem Spieler die Nachricht, sodass er es auch weiß.
SendClientMessage(playerid, COLOR_RED, "Du sitzt auf einem Fahrrad. Das hat keinen Motor!");
}
else if (Motor[car] == false) // Ansonsten, wenn der Motor des Fahrzeugs ausgeschaltet ist (haben wir ja oben mit dem bool Motor definiert)
{
GetVehicleParamsEx(car,engine,lights,alarm,doors,bonnet,boot,objective); // Selbe Prozedur wie oben
SetVehicleParamsEx(car,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective); // Selbe Prozedur wie oben, nur dass der Motor nun eingeschaltet wird.
Motor[car] = true; // Setzt den Bool Motor auf true
}
else // Ansonsten, wenn der Motor an ist
{
GetVehicleParamsEx(car,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(car,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
Motor[car] = false; // Setzt den Bool wieder auf falsch zurück.
}
}
return 1;
}
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(GetVehicleModel(vehicleid) == 509 GetVehicleModel(vehicleid) == 481 GetVehicleModel(vehicleid) == 510) // Überprüft ob das Fahrzeug ein Fahrrad ist (wie im Command oben)
{
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective); // Speichere den derzeitigen Status
SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective); // Behalte alles bei, aber starte den Motor.
}
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 OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}
public OnPlayerUpdate(playerid)
{
if(GetPlayerVehicleSeat(playerid) == 0)
{
new vehicleid;
vehicleid = GetPlayerVehicleID(playerid);
if(GetVehicleModel(vehicleid) != 509 && GetVehicleModel(vehicleid) != 481 && GetVehicleModel(vehicleid) != 510)
{
new string[125];
if(Tank[vehicleid] < 10) format(string,sizeof string,"~w~Tank: ~r~%i",Tank[vehicleid]);
else if(Tank[vehicleid] < 30) format(string,sizeof string,"~w~Tank: ~y~%i",Tank[vehicleid]);
else if(Tank[vehicleid] <= 100) format(string,sizeof string,"~w~Tank: ~g~%i",Tank[vehicleid]);
TextDrawSetString(Anzeige[playerid],string);
}
}
else
{
TextDrawSetString(Anzeige[playerid], " ");
}
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
hab 14 fehler...
C:\Users\dawid\Desktop\Tanksystem.pwn(3) : error 017: undefined symbol "MAX_PLAYERS"
C:\Users\dawid\Desktop\Tanksystem.pwn(3) : error 009: invalid array size (negative, zero or out of bounds)
C:\Users\dawid\Desktop\Tanksystem.pwn(7) : error 017: undefined symbol "MAX_VEHICLES"
C:\Users\dawid\Desktop\Tanksystem.pwn(7) : error 009: invalid array size (negative, zero or out of bounds)
C:\Users\dawid\Desktop\Tanksystem.pwn(10) : error 017: undefined symbol "MAX_VEHICLES"
C:\Users\dawid\Desktop\Tanksystem.pwn(93) : error 029: invalid expression, assumed zero
C:\Users\dawid\Desktop\Tanksystem.pwn(93) : error 017: undefined symbol "vehicleid"
C:\Users\dawid\Desktop\Tanksystem.pwn(95) : error 017: undefined symbol "vehicleid"
C:\Users\dawid\Desktop\Tanksystem.pwn(96) : error 017: undefined symbol "vehicleid"
C:\Users\dawid\Desktop\Tanksystem.pwn(97) : error 017: undefined symbol "vehicleid"
C:\Users\dawid\Desktop\Tanksystem.pwn(98) : warning 217: loose indentation
C:\Users\dawid\Desktop\Tanksystem.pwn(102) : warning 225: unreachable code
C:\Users\dawid\Desktop\Tanksystem.pwn(102) : warning 217: loose indentation
C:\Users\dawid\Desktop\Tanksystem.pwn(127) : warning 217: loose indentation
C:\Users\dawid\Desktop\Tanksystem.pwn(164) : error 029: invalid expression, assumed zero
C:\Users\dawid\Desktop\Tanksystem.pwn(164) : warning 215: expression has no effect
C:\Users\dawid\Desktop\Tanksystem.pwn(164) : error 001: expected token: ";", but found "if"
C:\Users\dawid\Desktop\Tanksystem.pwn(164) : error 017: undefined symbol "COLOR_RED"
C:\Users\dawid\Desktop\Tanksystem.pwn(164) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
14 Errors.