Jump to content

Tox

Members
  • Posts

    77
  • Joined

  • Last visited

Posts posted by Tox

  1. just bought MTA package and it's rockin'. they helped me a lot, i was having hard times to configure my own server. up time is a real problem nowadays but these guys are serious about that. it's not like some other cheeky vps provider who sells you :~ covered with gold. about the performance, i can't really say anything about that since there are no players on my server currently but i think the server will overcome that too. 10/10 would recommend

  2. Here is all what you need.
    local timerTable = {} -- timer table 
      
    -- save the time on player quit 
    function save () 
            local playerAccount = getPlayerAccount ( source ) -- get the player account 
            if (isTimer(timerTable[source])) then -- if the timer exist then  
            local remaining = getTimerDetails(timerTable[source]) -- then get the timer details 
            if playerAccount and not isGuestAccount(playerAccount) then -- check if it's not a guest account 
                setAccountData(playeraccount,  "timer", tonumber(remaining)) -- save the timer using setAccountData 
                killTimer(timerTable[source]) -- kill the timer 
                timerTable[source] = nil 
            end 
        end 
    end 
    addEventHandler ("onPlayerQuit", root, save ) 
      
    -- load the timer on player login 
    function loadTimer (_,account) 
        local timer = getAccountData(account, "timer") -- get the timer using getAccountData 
        if (timer) then -- if the timer exist then 
            timerTable[source] = setTimer(function() end, tonumber(time), 1) -- start it again using setTimer 
        end 
    end 
    addEventHandler ("onPlayerLogin", root, loadTimer) 
    

    your code won't work

  3.     --Set Skin 
    local inValidSkins = {[94] = true} -- replace teamName with the team you want 
      
    addEvent("AdminPanel.setSkin", true) 
        function setSkin(plr, getText) 
            if plr and isElement(plr) then 
                if getText then 
                    local skin = getElementModel(getText) 
                    if not skin then 
                        skin = getText 
                    end 
                    if inValidSkins[skin] then -- you can use getElementModel or simply replace it with getText 
                        outputChatBox("#00FF00Este team es solo para #FF0000[ADM]#00FF00 o#FF0000 [LIDER]", client, r, g, b, true) 
                        return 
                    end 
                    setElementModel(plr, skin) 
                    outputChatBox("#FF0000" ..getPlayerName(client).."#00FF00 Ha combiar su skin a #0B00FF("..skin..") ", plr, 0, 255, 0, true) 
                outputChatBox("#00FF00Combiar #FF0000"..getPlayerName(plr).."#00FF00 skin a #0B00FF("..skin..") ", client, 0, 255, 0, true) 
            end 
        end 
    end 
    addEventHandler("AdminPanel.setSkin", root, setSkin) 
    

  4.   
    function onLogin (_, playeraccount) 
        if ( playeraccount ) then 
         local Timer = getAccountData ( playeraccount, "timercd" ) 
                 if ( Timer ) then 
                 timer[source] = setTimer(function() 
                 timer[source] = nil 
                 outputChatBox("You can now use the advert again", source) 
                  end, Timer, 1) 
                    end 
                       end 
                          end 
        addEventHandler ( "onPlayerLogin", getRootElement ( ), onLogin) 
    

  5. 'source' is a userdata which is unique for every each element. so every time a player quits/joins they'll have a different userdata. you can save the timer's details with getTimerDetails function on player's account data when they quit and then work it after they join

  6. well yeah, of course i checked it out. i kind of understand what metatables do but the thing i am having a trouble with is what is metatables' advantage. i mean, can i still do the same things as metatables do without having to use metatables?

  7. what is the advantage of metatables? i've been coding for 8 months now, i've seen several examples of setmetatable here and there, still couldn't figure out what it does/how does it work. any comment is appreciated

  8. You would switch between the positions and update a different screen source every time I guess.

    This will cut your fps in half and will cause even bigger problems when the two positions are too far from each other.

    Search for rear view mirrors resources for an example.

    Seems cool at first but brings too many problems.

    i think i won't do it because of the performance issues, thank you for help

  9. hello, i am trying to do something like camera on a certain point of player's screen, at first i thought dxCreateScreenSource was the right function but here's the thing: i am trying to get the screen of another player. not the source player so, i need to use getElementPosition somehow but the function only captures the local player's screen. oh and i need it like a camera which means it will update when it is active. not just like a screenshot from another player's screen, i would be grateful if you can help me

    here's a video, that explains more:

  10. remove "thePlayer" argument and replace it with client

      
    function loginPlayer(username, password) 
        local account = getAccount(username, password) 
        if (account ~= false) then 
        logIn(client, account, password) 
        else 
            outputChatBox("Invalid username & password!", client, 255, 0, 0) 
            end 
        end 
        addEvent("loginPlayer", true) 
        addEventHandler("loginPlayer", getRootElement(), loginPlayer) 
      
    

  11. element data and table are the same things, however element data is synced on both client and server. if you want to store movements you'll want to store them in a table instead, and no i don't think it'd lag much if you set a limit for rewind time according to movements for example if it shows only 30 seconds back, it wouldn't lag much i guess, never tried something like that before though

  12. local images ={ 
        "Main/files/images/menu_bg1.jpg", 
        "Main/files/images/menu_bg2.jpg", 
        "Main/files/images/menu_bg3.jpg", 
        "Main/files/images/menu_bg4.jpg", 
        "Main/files/images/menu_bg5.jpg", 
        "Main/files/images/menu_bg6.jpg" 
    } 
    local ap = 0 
    local id = 1 
    local tick = getTickCount() 
    local function setId() 
        id = id + 1  
        if id >= #images then  
            id = 1  
        end  
         
        tick = getTickCount () + 3000 
    end  
    setTimer (setId, 5000, 1) 
      
    function fade ()  
        if ap >= 255 then  
            if getTickCount () >= tick then 
                ap = ap - 5 
            end  
        else 
            ap = ap + 5 
        end  
    end  
      
    function testBackground() 
        fade()   
        dxDrawImage(s[1]*0/1440,s[2]*0/900, s[1]*1440/1440,s[2]*900/900, images[id], 0, 0, 0, tocolor(255, 255, 255, ap),false) 
    end 
    addEventHandler ("onClientRender", root, testBackground) 
    

  13. i have done something similar but i don't suggest it because you have to giveWeapon every time player changes slot, also it's not very reliable. it causes lag and if the server is lagging player will get the weapon in delay so yeah this could cause some problem. nevertheless, if you still want to do it you'll use these;

    [url=https://wiki.multitheftauto.com/wiki/OnPlayerWeaponSwitch]https://wiki.multitheftauto.com/wiki/On ... aponSwitch[/url], [url=https://wiki.multitheftauto.com/wiki/GiveWeapon]https://wiki.multitheftauto.com/wiki/GiveWeapon[/url]  
    

    and of course you must be familiar with lua tables to make it work correctly, good luck

  14. clickedWorld: This represents any physical entity elements that were clicked. If the player clicked on no MTA element, it's set to false.

    you can use onClientGUIClick instead

×
×
  • Create New...