17.05.2009, 14:38
I have a big problem. I want to make a Speedometer for my Server but I don't understand, why it doesn't work:
I have the Speedo sourcecode once in a filterscript and once in a gamemode. But the Speedo only works in the gamemode. In the filterscript, the Speedo doesn't announced.
although it's the same code:
gamemode:
filterscript:
I don't understand it, please help me
I have the Speedo sourcecode once in a filterscript and once in a gamemode. But the Speedo only works in the gamemode. In the filterscript, the Speedo doesn't announced.
although it's the same code:
gamemode:
Code:
#include <a_samp>
forward TankVerbrauch(playerid);
forward Fahrzeuganzeige(playerid);
new Float:newX[MAX_PLAYERS], Float:newY[MAX_PLAYERS], Float:newZ[MAX_PLAYERS];
new Float:oldX[MAX_PLAYERS], Float:oldY[MAX_PLAYERS], Float:oldZ[MAX_PLAYERS];
new Float:diffX[MAX_PLAYERS], Float:diffY[MAX_PLAYERS], Float:diffZ[MAX_PLAYERS];
new Float:Num[MAX_PLAYERS];
new FahrzeugID;
new Tankinhalt[MAX_VEHICLES];
new GameText;
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
public OnGameModeInit()
{
SetTimer("TankVerbrauch",5000, true);
SetTimer("Fahrzeuganzeige",1000,1);
GameText = 0;
new Vehicles;
for(Vehicles = 0; Vehicles < MAX_VEHICLES; Vehicles++)
{
Tankinhalt[Vehicles] = 100;
}
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
AddStaticVehicle(581, 1958.3783, 1343.1572, 15.3746, 269.1425,53,1);
AddStaticVehicle(581, 1958.3783, 1343.1572, 15.3746, 269.1425,53,1);
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 TankVerbrauch(playerid)
{
if(GameText == 0)
{
FahrzeugID = GetPlayerVehicleID(playerid);
if(IsPlayerInAnyVehicle(playerid))
{
Tankinhalt[FahrzeugID] -= 1;
}
}
}
public Fahrzeuganzeige(playerid)
{
for(new i=0; i<MAX_PLAYERS; i++)
{
new string[256];
FahrzeugID = GetPlayerVehicleID(i);
if(IsPlayerInAnyVehicle(playerid) == 1)
{
GetPlayerPos(playerid, newX[i],newY[i], newZ[i]);
diffX[i] = (newX[i]) - (oldX[i]); diffY[i] = (newY[i]) - (oldY[i]); diffZ[i] = (newZ[i]) - (oldZ[i]);
Num[i] = floatsqroot((diffX[i] * diffX[i])+(diffY[i] * diffY[i])+(diffZ[i] * diffZ[i]));
oldX[i] = newX[i]; oldY[i] = newY[i]; oldZ[i] = newZ[i];
Num[i] = Num[i] * 4;
if(Tankinhalt[FahrzeugID] > 0)
{
if(Tankinhalt[FahrzeugID] < 31)
{
format(string, sizeof(string), "~n~~n~~n~~n~~n~~n~~n~~n~~g~%0.0f/~r~%d", Num[i],Tankinhalt[FahrzeugID]);
GameTextForPlayer(i,string,1500,5);
}
else
{
format(string, sizeof(string), "~n~~n~~n~~n~~n~~n~~n~~n~~g~%0.0f/~g~%d", Num[i],Tankinhalt[FahrzeugID]);
GameTextForPlayer(i,string,1500,5);
}
}
else
{
RemovePlayerFromVehicle(playerid);
}
}
}
}
Code:
#include <a_samp>
forward TankVerbrauch(playerid);
forward Fahrzeuganzeige(playerid);
new GameText;
new Float:newX[MAX_PLAYERS], Float:newY[MAX_PLAYERS], Float:newZ[MAX_PLAYERS];
new Float:oldX[MAX_PLAYERS], Float:oldY[MAX_PLAYERS], Float:oldZ[MAX_PLAYERS];
new Float:diffX[MAX_PLAYERS], Float:diffY[MAX_PLAYERS], Float:diffZ[MAX_PLAYERS];
new Float:Num[MAX_PLAYERS];
new FahrzeugID;
new Tankinhalt[MAX_VEHICLES];
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
SetTimer("TankVerbrauch",5000, true);
SetTimer("Fahrzeuganzeige",1000,1);
GameText = 0;
new Vehicles;
for(Vehicles = 0; Vehicles < MAX_VEHICLES; Vehicles++)
{
Tankinhalt[Vehicles] = 100;
}
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
AddStaticVehicle(581, 1958.3783, 1343.1572, 15.3746, 269.1425,53,1);
AddStaticVehicle(581, 1958.3783, 1343.1572, 15.3746, 269.1425,53,1);
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#endif
public OnGameModeInit()
{
// 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 TankVerbrauch(playerid)
{
if(GameText == 0)
{
FahrzeugID = GetPlayerVehicleID(playerid);
if(IsPlayerInAnyVehicle(playerid))
{
Tankinhalt[FahrzeugID] -= 1;
}
}
}
public Fahrzeuganzeige(playerid)
{
for(new i=0; i<MAX_PLAYERS; i++)
{
new string[256];
FahrzeugID = GetPlayerVehicleID(i);
if(IsPlayerInAnyVehicle(playerid) == 1)
{
GetPlayerPos(playerid, newX[i],newY[i], newZ[i]);
diffX[i] = (newX[i]) - (oldX[i]); diffY[i] = (newY[i]) - (oldY[i]); diffZ[i] = (newZ[i]) - (oldZ[i]);
Num[i] = floatsqroot((diffX[i] * diffX[i])+(diffY[i] * diffY[i])+(diffZ[i] * diffZ[i]));
oldX[i] = newX[i]; oldY[i] = newY[i]; oldZ[i] = newZ[i];
Num[i] = Num[i] * 4;
if(Tankinhalt[FahrzeugID] > 0)
{
if(Tankinhalt[FahrzeugID] < 31)
{
format(string, sizeof(string), "~n~~n~~n~~n~~n~~n~~n~~n~~g~%0.0f/~r~%d", Num[i],Tankinhalt[FahrzeugID]);
GameTextForPlayer(i,string,1500,5);
}
else
{
format(string, sizeof(string), "~n~~n~~n~~n~~n~~n~~n~~n~~g~%0.0f/~g~%d", Num[i],Tankinhalt[FahrzeugID]);
GameTextForPlayer(i,string,1500,5);
}
}
else
{
RemovePlayerFromVehicle(playerid);
}
}
}
}

