[help] Timers -
jeffery30162 - 14.06.2013
Ive made a business system and i have npc's in each business and I want players to be able to rob them but i need help making two timers one for the player and one for the businesses.
Player timer:
A timer for how often a player can rob a business
Time between robs: 2 minutes
Business timer:
A timer for how often the business can be robbed
Time between robs: 5 minutes
Heres my business enum:
Код:
enum bizInfo
{
bType,
bStatus,
bOwner[32],
Float:bX,
Float:bY,
Float:bZ,
bPickup,
bMoney,
bProducts,
Text3D:bText,
bNpcL,
bSold,
bLevel,
bPrice,
bAP,
bNpc[32],
bNpcS,
bNpcI,
bRecentlyRobbed,
bRobTimer
}
For business I will be using bRobTimer as the timer for each business
Player unum:
Код:
enum pInfo
{
// Temp Values
LoggedIn,
Spawn,
Zombie,
ZInfected,
// Permanent Values
pIP,
Gender,
Age,
Level,
pScore,
pSkin,
Money,
pAdmin,
pJob,
WantedLevel,
Float:pX,
Float:pY,
Float:pZ,
Tutorial,
Banned,
pScope,
VW,
Int,
pDeath,
pFac,
pKill,
Float:Health,
Float:Armour,
pWeapon[13],
pWeaponAmmo[13],
// VIP
pVIP,
// VIP Job
pVIPJob,
// Spawns //
pHospital,
pPrison,
pPrisonTime,
//Hitman//
pContract,
pCSuccess,
pCFail,
//Prison//
pPrisonReason[64],
pPrisonBy[32],
//Factions//
pFacDuty,
//Businesses//
pBiz,
pVBiz,
pOwner,
//Robbery Guage//
RobTime,
RobTimer
}
For players I will be using the RobTimer enum for each player.
please help me im stuck
Re: [help] Timers -
Anak - 14.06.2013
https://sampwiki.blast.hk/wiki/SetTimer
https://sampwiki.blast.hk/wiki/SetTimerEx
AW: [help] Timers -
NaS - 14.06.2013
I wouldn't use a timer here, since it's not needed!
Use GetTickCount (returns current timestamp in milliseconds).
If the player robbed a business, set a variable (in your enum) to the current time stamp (GetTickCount()):
Businesses[ID][bLastRobbed] = GetTickCount();
To check, if the business can be robbed again:
if(GetTickCount() - Businesses[ID][bLastRobbed] > 300000) // Gets the time-difference in ms to compare
{
// Player can rob the business!
}
Same for the players ofc.
No need for a timer, and even easier.
Re: [help] Timers -
Pottus - 14.06.2013
That is right, this is not a timer situation in anyway shape or form.