02.08.2009, 18:01
Hello Folks,
I've got a problem with some code for a reallife-script.
I've wanted to let a vehicle gas up in a checkpoint at petrol station.
I'm using the CPS by DragSta for creating the checkpoints.
My Code's the following:
Since I'm a German, the text's are German too, but that doesn't matter.
Now my problems are:
1. in both "format" the "%%" doesn't show a "%" in the game.
2. the fueling should stop on leaving the Checkpoint, but it doesn't.
I could fix the second problem by using SetTimer(and KillTimer). Am I right? Maybe I will test that.
But what's about the "%%" problem?
Thankful D3nnis
I've got a problem with some code for a reallife-script.
I've wanted to let a vehicle gas up in a checkpoint at petrol station.
I'm using the CPS by DragSta for creating the checkpoints.
My Code's the following:
pawn Код:
#define MAX_PETROLS 12
new Tankstelle[MAX_PETROLS];
new Fuel[MAX_PLAYERS];
new OLD_Fuel[MAX_PLAYERS];
new IsInCheckpoint[MAX_PLAYERS];
Sleep(time)
{
new StartTime = GetTickCount();
while(GetTickCount() - StartTime < time)
{
//do nothing
}
return 1;
}
public OnPlayerSpawn(playerid)
{
Tankstelle[0] = CreateCheckpoint(playerid, 132.8586,-123.9499,1.4297,8,150); // Tankstelle in der Nдhe von 0-0-0
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
IsInCheckpoint[playerid]=1;
CheckpointCheck(playerid);
return 1;
}
public OnPlayerEnterStreamedCheckpoint(playerid, streamid)
{
GameTextForPlayer(playerid, "Checkpoint", 2000, 4);
if(streamid == Tankstelle[0])
{
if(IsPlayerInAnyVehicle(playerid)) Tanken(playerid);
else SendClientMessage(playerid, BLUE, "Tanken ist nur im Fahrzeug mцglich");
}
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
IsInCheckpoint[playerid]=0;
return 1;
}
Tanken(playerid)
{
if(Fuel[playerid] != 100)
{
new string[128];
OLD_Fuel[playerid]=Fuel[playerid];
while(IsInCheckpoint[playerid]==1&&Fuel[playerid]<100)
{
Fuel[playerid]++;
format(string, sizeof(string), "Tanken.. %i %%", Fuel[playerid]);
SendClientMessage(playerid, GREEN, string);
Sleep(500);
}
OLD_Fuel[playerid]=Fuel[playerid]-OLD_Fuel[playerid];
format(string, sizeof(string), "Du hast %i %% getankt, das macht dann %i $", OLD_Fuel[playerid], OLD_Fuel[playerid]*3);
GivePlayerMoney(playerid, -OLD_Fuel[playerid]*3);
}
else SendClientMessage(playerid, GREEN, "Dein Tank ist voll!");
}
Now my problems are:
1. in both "format" the "%%" doesn't show a "%" in the game.
2. the fueling should stop on leaving the Checkpoint, but it doesn't.
I could fix the second problem by using SetTimer(and KillTimer). Am I right? Maybe I will test that.
But what's about the "%%" problem?
Thankful D3nnis