Jump to content

Problem with time jail


Destroyer.-

Recommended Posts

Posted

I have a problem with showing the time in jail, I is not updated, try to do it in client-side but I could not because I have the timer on server-side, so I wanted to do so but could not: /

  
function showTextDisplay ( player, command ) 
   local serverDisplay = textCreateDisplay()         
if isTimer(timers[player]) then  
   textDisplayAddObserver ( serverDisplay, player )                      -- make it visible to a player 
   local serverText = textCreateTextItem ( "Tiempo Restante: "..getTimerDetails(timers[player]), 0.5, 0.5 )    -- create a text item for the display 
   textDisplayAddText ( serverDisplay, serverText )                      -- add it to the display so it is displayed 
end 
end 
addCommandHandler( "timer", showTextDisplay ) 
  

hopefully can help me, thanks :/

Posted

I don't recommend creating the timers on the server side, I would do it client side instead, and then you can draw the remaining time using DX functions.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
I don't recommend creating the timers on the server side, I would do it client side instead, and then you can draw the remaining time using DX functions.

The problem is how to save the timer if i can not use SQL to client-side, not how to do it: /

Help pls :c

Posted

Well, you can always sync the time left using element data.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
Well, you can always sync the time left using element data.

There is no way to do client-side, but the timer on server-side? because you do not know how I can think of: S

Server-side

  
function player_Wasted ( ammo, attacker, weapon, bodypart ) 
    if attacker and getElementType(attacker) == "player" then 
    local arrestado = getElementData(source, "arrestado") or 0 
    local level = getPlayerWantedLevel(source) 
    local acc = getPlayerAccount(source) 
  
    if skins[getElementModel(attacker)] and level > 0  then 
       local arresto = setAccountData(acc,"arresto",1) 
        if arresto==0 then return end 
  
        setTimer (fadeCamera, 2000, 1, source, false) 
        setTimer (setCameraTarget, 4000, 1, source, source) 
        setTimer (fadeCamera, 6000, 1, source, true) 
        setTimer (spawnPlayer, 6001, 1,  source, 4076.3999023438, -1788.5, 3.511967, 0, getElementModel (source), 0, 0, getPlayerTeam(source)) 
  
        outputChatBox ( "Fuiste Arrestado Por "..getPlayerName ( attacker ).." por 100 segundos.", source,255,0,0 ) 
        givePlayerMoney (attacker, 1000) 
        outputChatBox ( "Arrestaste a "..getPlayerName(source), attacker,255,255,0 ) 
  
            local player = source 
            timers[source] = setTimer ( function(p) 
                local p = player 
                while type(p) == "userdata" do -- uso while para hacer un ciclo que me indique si 'p' es un dato de usuario. 
                setElementPosition ( p, 1544.4332275391, -1674.7698974609, 13.688399200439 ) 
                setPlayerWantedLevel ( p,0)  
                sendClientMessage ( "Saliste de Prision.", p, 0, 255, 0, false ) 
                setAccountData(acc,"arresto",0) 
                 
                 
                 
                p = nil -- retorno la variable 'p' a nula. De otra manera al no hacer esto la función entra en un ciclo infinito. 
            end 
        
            end, 100000, 1 ) 
          
          end      
    end 
end 
addEventHandler ("onPlayerWasted", getRootElement(), player_Wasted) 
  

Client-side

  
local screenWidth, screenHeight = guiGetScreenSize ( ) -- Get the screen resolution (width and height) 
function math.round(number, decimals, method) 
    decimals = decimals or 0 
    local factor = 10 ^ decimals 
    if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor 
    else return tonumber(("%."..decimals.."f"):format(number)) end 
end 
function draw() 
    left, _, _ = getTimerDetails(timers[source]) 
    lefts = math.round(left/1000) 
      dxDrawText ( "Time Left: "..lefts, 44, screenHeight - 41, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown" ) 
end 
addEventHandler ( "onClientRender", getLocalPlayer(), draw ) 
  

But, dont work, can you help me please? ;/

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...