Skip to content

Commit

Permalink
Default value of timers (#820)
Browse files Browse the repository at this point in the history
Timers need to be reset to 0
  • Loading branch information
pushline authored Jan 10, 2024
1 parent 09db433 commit 287b8ef
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions docs/scripting/functions/GetPlayerPing.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ The current ping of the player (expressed in milliseconds).

```c
// Declare an array of all possible timer identifiers for timers for kicking players with
// generally high ping with default value of -1
// generally high ping with default value of 0
new
gPlayerPingTimer[MAX_PLAYERS] = {-1, ...};
gPlayerPingTimer[MAX_PLAYERS] = {0, ...};

// A constant (nice documentation :))
const
Expand All @@ -38,7 +38,7 @@ public OnPlayerDisconnect(playerid, reason)
{
// Kill the timer and reset the value to invalid
KillTimer(gPlayerPingTimer[playerid]);
gPlayerPingTimer[playerid] = -1;
gPlayerPingTimer[playerid] = 0;
}

// A forwarded function (callback)
Expand Down
4 changes: 2 additions & 2 deletions docs/scripting/functions/KillTimer.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This function always returns 0.

```c
new
gConnectTimer[MAX_PLAYERS] = {-1, ...};
gConnectTimer[MAX_PLAYERS] = {0, ...};

public OnPlayerConnect(playerid)
{
Expand All @@ -32,7 +32,7 @@ public OnPlayerConnect(playerid)
public OnPlayerDisconnect(playerid)
{
KillTimer(gConnectTimer[playerid]);
gConnectTimer[playerid] = -1;
gConnectTimer[playerid] = 0;
return 1;
}

Expand Down
6 changes: 3 additions & 3 deletions docs/scripting/functions/SetVehicleParamsEx.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Sets a vehicle's parameters for all players.
```c
// On top of our script, declaring a global variable
new
gVehicleAlarmTimer[MAX_VEHICLES] = {-1, ...};
gVehicleAlarmTimer[MAX_VEHICLES] = {0, ...};

// If setting a single parameter, you should obtain the current parameters so they aren't ALL changed
new
Expand All @@ -50,7 +50,7 @@ SetVehicleParamsEx_Fixed(vehicleid, &engine, &lights, &alarm, &doors, &bonnet, &
{
// Kill the timer, reset the timer identifier and then restart it if it was already running
KillTimer(gVehicleAlarmTimer[vehicleid]);
gVehicleAlarmTimer[vehicleid] = -1;
gVehicleAlarmTimer[vehicleid] = 0;
gVehicleAlarmTimer[vehicleid] = SetTimerEx("DisableVehicleAlarm", 20000, false, "d", vehicleid);
}
}
Expand All @@ -68,7 +68,7 @@ public DisableVehicleAlarm(vehicleid)
}

// Reset the timer identifier
gVehicleAlarmTimer[vehicleid] = -1;
gVehicleAlarmTimer[vehicleid] = 0;
}
```
Expand Down
4 changes: 2 additions & 2 deletions docs/translations/bs/scripting/functions/KillTimer.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Ova funkcija uvijek returna/vraća 0.

```c
new
gConnectTimer[MAX_PLAYERS] = {-1, ...};
gConnectTimer[MAX_PLAYERS] = {0, ...};

public OnPlayerConnect(playerid)
{
Expand All @@ -32,7 +32,7 @@ public OnPlayerConnect(playerid)
public OnPlayerDisconnect(playerid)
{
KillTimer(gConnectTimer[playerid]);
gConnectTimer[playerid] = -1;
gConnectTimer[playerid] = 0;
return 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Postavlja parametre vozila za sve igrače.
```c
// Na vrhu naše skripte, deklarišemo globalnu varijablu
new
gVehicleAlarmTimer[MAX_VEHICLES] = {-1, ...};
gVehicleAlarmTimer[MAX_VEHICLES] = {0, ...};

// Ako postavljate jedan parametar, trebali biste dobiti trenutne parametre kako se ne bi SVE promijenili
new
Expand All @@ -54,7 +54,7 @@ SetVehicleParamsEx_Fixed(vehicleid, &engine, &lights, &alarm, &doors, &bonnet, &
{
// Ubij tajmer, resetirajte identifikator tajmera, a zatim ga ponovo pokrenite ako je već bio pokrenut
KillTimer(gVehicleAlarmTimer[vehicleid]);
gVehicleAlarmTimer[vehicleid] = -1;
gVehicleAlarmTimer[vehicleid] = 0;
gVehicleAlarmTimer[vehicleid] = SetTimerEx("DisableVehicleAlarm", 20000, false, "d", vehicleid);
}
}
Expand All @@ -72,7 +72,7 @@ public DisableVehicleAlarm(vehicleid)
}

// Reset the timer identifier
gVehicleAlarmTimer[vehicleid] = -1;
gVehicleAlarmTimer[vehicleid] = 0;
}
```
Expand Down
6 changes: 3 additions & 3 deletions docs/translations/th/scripting/functions/GetPlayerPing.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ The current ping of the player (expressed in milliseconds).

```c
// Declare an array of all possible timer identifiers for timers for kicking players with
// generally high ping with default value of -1
// generally high ping with default value of 0
new
gPlayerPingTimer[MAX_PLAYERS] = {-1, ...};
gPlayerPingTimer[MAX_PLAYERS] = {0, ...};

// A constant (nice documentation :))
const
Expand All @@ -38,7 +38,7 @@ public OnPlayerDisconnect(playerid, reason)
{
// Kill the timer and reset the value to invalid
KillTimer(gPlayerPingTimer[playerid]);
gPlayerPingTimer[playerid] = -1;
gPlayerPingTimer[playerid] = 0;
}

// A forwarded function (callback)
Expand Down

0 comments on commit 287b8ef

Please sign in to comment.