20.08.2011, 16:17
i want to mention that you can use the pickups (inclusive any desired amount of time) to use for capturing zones. iam in a hurry, so there will be some bugs:
the precision is not that precise like a timer, but who gives a fuck for max. 1 second tolerance? i dont
the idea with =="leaving pickup" can be reversed to !="still touching pickup". plus: w/o any need for yet 1 more timer... sry if theres a concept bug, give it a try
if you leave the pickup, you wont get any message unless you capture the zone. thats the downside, and you need to add a check if the "old" stored time is >20000 ms away (left pickups earlier), so you need to initialize it again >-<
Code:
OPPU() { If(GetPVarInt(playerid,"StayingInPickupAlreadySinceMS")==0 || GetTickCount()-GetPVarInt(playerid,"StayingInPickupAlreadySinceMS")>20000)//if not set (or deleted from last capture) then set the pvar to the actual servertime { SetPVarInt(playerid,"StayingInPickupAlreadySinceMS",GetTickCount()); return 1; } else//its >0, so the player already touched the pickup. time to calculate the difference: { SetPVarInt(playerid,"StayingInPickupAlreadyHowLongMS",GetTickCount()-GetPVarInt(playerid,"StayingInPickupAlreadySinceMS")); if(GetPVarInt(playerid,"StayingInPickupAlreadyHowLongMS")>20000) { //zone captured. DONT forget to erase the pvars aswell DeletePVar(playerid,"StayingInPickupAlreadySinceMS"); DeletePVar(playerid,"StayingInPickupAlreadyHowLongMS"); } else { //capture failed, coz the player is not touching the pickups anymore DeletePVar(playerid,"StayingInPickupAlreadySinceMS"); DeletePVar(playerid,"StayingInPickupAlreadyHowLongMS"); } } }
the idea with =="leaving pickup" can be reversed to !="still touching pickup". plus: w/o any need for yet 1 more timer... sry if theres a concept bug, give it a try
if you leave the pickup, you wont get any message unless you capture the zone. thats the downside, and you need to add a check if the "old" stored time is >20000 ms away (left pickups earlier), so you need to initialize it again >-<