Jump to content

Triggering a client event holding timer details.


Ab-47

Recommended Posts

Posted

Hey, it's been a while since I've asked for help, but I really need it this time :3 I don't know if I'm just to tired to think straight or I just don't know, but I'm sure you guys could help me out.

So here's my problem, I cant seem to trigger timer details of a set timer to my client file to output using DX text. It gives me errors when trying to output the sent details. The triggering works fine now, as of before it used to give debug errors showing it's expected an lua-timer or whatever.

--(Server Sided) 
timedTimer = setTimer(theFunction, 100000, 1, turfName, ePlayerGroup, ePlayer) 
triggerClientEvent(ePlayer, "MTA_RP_turfing.showTimedStatus", ePlayer, timedTimer) 
  

--(Client Sided) 
function showTimedStatus(timedTimer) 
    timedTimer = timeRemaining 
    addEventHandler("onClientRender", root, renderTimeLeft) 
end 
addEvent("MTA_RP_turfing.showTimedStatus", true) 
addEventHandler("MTA_RP_turfing.showTimedStatus", root, showTimedStatus) 
  
function renderTimeLeft() 
    timeLeft = getTimerDetails(timeRemaining) 
    local x = math.ceil(timeLeft/1000) 
    dxDrawRectangle((680/824) * screenWidth, (590/687.4) * screenHeight, x / 0.5, 22.9, tocolor(157, 0, 0, 117.5)) 
    exports.MTA_RP_texts:boldText("Capturing turf: "..tostring(x).."", (688/398)*screenWidth,(600/702)*screenHeight, 100, 100, tocolor(255, 255, 255, 255), 0.73, theFont, "center", "top", false, false, false) 
end 
  

Errors:

Bad Argument @ 'getTimerDetails' [Expected lua-timer at argument 1, got nil]

attempt to perform arithmetic on global 'timeLeft' (a boolean value)

I've tried changing arguments, variables and getting the code to recognise the timer but it's useless. To find a way around all this I triggered the client event to trigger a new timer, but that has allot of exploits so I need to fix this issue whenever possible. Thanks for reading, would be really appreciated if anyone could help :)

Posted
Get timer's left time before triggering, stop the timer, trigger the time left and start timer client-side.

Could you elaborate, or at-least post a code on how to?

Posted
Get timer left time -> kill timer -> trigger left time -> create timer

Wouldn't it be easier using custom intervals? I might just try that. And can you show me an example in code of what you mean? It'll be easier.

Posted

1. Your timer only runs one time.

2. Do you have the function theFunction() ?

3. Is the event triggered randomly ? Like, you need to do something to trigger it ?

Posted
1. Your timer only runs one time.

2. Do you have the function theFunction() ?

3. Is the event triggered randomly ? Like, you need to do something to trigger it ?

Well it's a turfing script so;

1) When someone enters a turf, it's triggered to that simple function

2) No it's not named theFunction(), I reduced variable length for your understanding. I'm experienced enough to change the variable back to it's normal one and I'd understand anything if you provided a code using theFunction().

3) No, as I said on (1), when someone enters a turf. To be more specific, when someone enters a turf that isn't owned by any. And that's not the issue because I've a full system to state the non-owned turfs.

Posted
1. Your timer only runs one time.

2. Do you have the function theFunction() ?

3. Is the event triggered randomly ? Like, you need to do something to trigger it ?

Well it's a turfing script so;

1) When someone enters a turf, it's triggered to that simple function

2) No it's not named theFunction(), I reduced variable length for your understanding. I'm experienced enough to change the variable back to it's normal one and I'd understand anything if you provided a code using theFunction().

3) No, as I said on (1), when someone enters a turf. To be more specific, when someone enters a turf that isn't owned by any. And that's not the issue because I've a full system to state the non-owned turfs.

Give me more Server-Side code so I know how it get's created.

Posted
Give me more Server-Side code so I know how it get's created.

You don't need more than what I provided.

You can trigger client with your desired timer length and use getTickCount to check how much time passed since the trigger

I'll probably try that..

What if I want this DX timer shown to all the players in a specific group? I've an export to get the players group..

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...