Incrementation (+REP)
#1

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:
PHP код:
switch (listitem)
            {
                case 
0:
                {
                    if (!
PlayerData[playerid][pOnDuty])
                    {
                        if(
GetFactionType(playerid) == FACTION_POLICE) { polservice++; }
                        
                        
PlayerData[playerid][pOnDuty] = true;
                        
SetPlayerArmour(playerid100.0);
                        
PlayerData[playerid][pTempsService]++; // INCREMENTATION
                        
SetFactionColor(playerid);
                        
SendNearbyMessage(playerid30.0COLOR_PURPLE"** %s prend son badge de son casier et est maintenant en service."ReturnName(playerid0));
                    }
                    else
                    {
                        if(
GetFactionType(playerid) == FACTION_POLICE) { polservice--; }
                        
PlayerData[playerid][pOnDuty] = false;
                        
SetPlayerArmour(playerid0.0);
                        
SetPlayerColor(playeridDEFAULT_COLOR);
                        
SetPlayerSkin(playeridPlayerData[playerid][pSkin]);
                            
//KillTimer(PlayerData[playerid][pTempsService]); // WHAT I SHOULD ADD HERE !? (The TempsService is stocked in the database.
                        
SendNearbyMessage(playerid30.0COLOR_PURPLE"** %s range son badge et est maintenant hors service."ReturnName(playerid0));
                    }
                }
                case 
1:
                {
                    
SetPlayerArmour(playerid100.0);
                    
SendNearbyMessage(playerid30.0COLOR_PURPLE"** %s ouvre le casier et prend un gilet pare-balle."ReturnName(playerid0));
                }
                case 
2:
                {
                    for (new 
0sizeof(skins); ++)
                        
skins[i] = (FactionData[factionid][factionSkins][i]) ? (FactionData[factionid][factionSkins][i]) : (19300);
                    
ShowModelSelectionMenu(playerid"Sйlйctionner Skin"MODEL_SELECTION_FACTION_SKINskinssizeof(skins), -16.00.0, -55.0);
                }
                case 
3:
                {
                    for (new 
010++)
                    {
                        if (
FactionData[factionid][factionWeapons][i])
                            
format(stringsizeof(string), "%sArme %d: %s\n"string1ReturnWeaponName(FactionData[factionid][factionWeapons][i]));
                        else 
format(stringsizeof(string), "%sEmplacement Vide\n"string);
                    }
                    
Dialog_Show(playeridLockerWeaponsDIALOG_STYLE_LIST"Casier d'Armes"string"Selectionner""Annuler");
                }
            } 
Reply
#2

To stop a timer use https://sampwiki.blast.hk/wiki/KillTimer. Save the ID of the timer by doing:

variable[index if needed] = SetTimer
Reply
#3

I already did that:
//KillTimer(PlayerData[playerid][pTempsService]); // WHAT I SHOULD ADD HERE !? (The TempsService is stocked in the database.
Reply
#4

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)