PDA

View Full Version : Incrementation (+REP)


Napst34
09/07/2016, 04:12 AM
Hi, I am editing the PayDay system, but I have a little problem.
When I have finished It worked but when a LSPD member is OFF duty the Service Timer don't stop!
Here is the code:
switch (listitem)
{
case 0:
{
if (!PlayerData[playerid][pOnDuty])
{
if(GetFactionType(playerid) == FACTION_POLICE) { polservice++; }

PlayerData[playerid][pOnDuty] = true;
SetPlayerArmour(playerid, 100.0);
PlayerData[playerid][pTempsService]++; // INCREMENTATION

SetFactionColor(playerid);
SendNearbyMessage(playerid, 30.0, COLOR_PURPLE, "** %s prend son badge de son casier et est maintenant en service.", ReturnName(playerid, 0));
}
else
{
if(GetFactionType(playerid) == FACTION_POLICE) { polservice--; }
PlayerData[playerid][pOnDuty] = false;
SetPlayerArmour(playerid, 0.0);
SetPlayerColor(playerid, DEFAULT_COLOR);
SetPlayerSkin(playerid, PlayerData[playerid][pSkin]);
//KillTimer(PlayerData[playerid][pTempsService]); // WHAT I SHOULD ADD HERE !? (The TempsService is stocked in the database.
SendNearbyMessage(playerid, 30.0, COLOR_PURPLE, "** %s range son badge et est maintenant hors service.", ReturnName(playerid, 0));
}
}
case 1:
{
SetPlayerArmour(playerid, 100.0);
SendNearbyMessage(playerid, 30.0, COLOR_PURPLE, "** %s ouvre le casier et prend un gilet pare-balle.", ReturnName(playerid, 0));
}
case 2:
{
for (new i = 0; i < sizeof(skins); i ++)
skins[i] = (FactionData[factionid][factionSkins][i]) ? (FactionData[factionid][factionSkins][i]) : (19300);

ShowModelSelectionMenu(playerid, "Séléctionner Skin", MODEL_SELECTION_FACTION_SKIN, skins, sizeof(skins), -16.0, 0.0, -55.0);
}
case 3:
{
for (new i = 0; i < 10; i ++)
{
if (FactionData[factionid][factionWeapons][i])
format(string, sizeof(string), "%sArme %d: %s\n", string, i + 1, ReturnWeaponName(FactionData[factionid][factionWeapons][i]));

else format(string, sizeof(string), "%sEmplacement Vide\n", string);
}
Dialog_Show(playerid, LockerWeapons, DIALOG_STYLE_LIST, "Casier d'Armes", string, "Selectionner", "Annuler");
}
}

SickAttack
09/07/2016, 04:40 AM
To stop a timer use http://wiki.sa-mp.com/wiki/KillTimer. Save the ID of the timer by doing:

variable[index if needed] = SetTimer

Napst34
09/07/2016, 05:36 AM
I already did that:
//KillTimer(PlayerData[playerid][pTempsService]); // WHAT I SHOULD ADD HERE !? (The TempsService is stocked in the database.

Napst34
09/07/2016, 05:42 AM
SOLVED!
I've added a Minute Check.
It checks each minute if the player is on duty
If yes +1 if not it do nothing.

+REP SickAttack for helping thx