Jump to content

cheez3d

Members
  • Posts

    290
  • Joined

  • Last visited

Everything posted by cheez3d

  1. playSound3D() attachElements()
  2. You can't divide a number by 0 so n/0=0 is not correct.
  3. Instead of setTimer use "onPlayerJoin", "onPlayerLeave" and "onElementDataChange" with setElementData(player,"wanted_level",getPlayerWantedLevel(player)).
  4. Maybe getElementsByType("sound") will help.
  5. addEventHandler("onClientRender",root,function() for i=0,360,0.25 do dxDrawLine(300,300,300+100*math.sin(math.rad(i)),300+100*math.cos(math.rad(i)),(i>=0 and i<=50) and tocolor(60,60,60) or (i>50 and i<=180) and tocolor(255,50,50) or (i>180 and i<=360) and tocolor(0,255,70)) end end) You can use this simple function for an output like this:
  6. You can use dxDrawLine with some math and tocolor to draw it. dxDrawLine() tocolor()
  7. CLIENT local gui = {edit = guiCreateEdit(200,200,150,30,"",false),button = guiCreateButton(200,250,150,30,"Spawn",false)} addEventHandler("onClientGUIClick",gui.button,function() triggerServerEvent("onPlayerRequestCar",localPlayer,string.match(guiGetText(gui.edit),"[0-9]") and tonumber(guiGetText(gui.edit)) or 497) end,false) SERVER addEvent("onPlayerRequestCar",true) addEventHandler("onPlayerRequestCar",root,function(id) if id then local x,y,z = getElementPosition(client) local rx,ry,rz = getElementRotation(client) createVehicle(id,x,y,z,rx,ry,rz) end end)
  8. addCommandHandler("drop",function(player) local x,y,z = getElementPosition(player) local weapon,ammo = getPedWeapon(player),getPedTotalAmmo(player) takeWeapon(player,weapon,ammo) createPickup(x+4,y,z+1,2,weapon,5000,ammo) end)
  9. That is why you have to execute the function on the player's client, not on yours, and then transfer the data to your client and draw the image.
  10. dxCreateScreenSource() -- get the screen of the criminals dxUpdateScreenSource() -- update the screen source every frame dxDrawImage() -- draw the texture returned by the function above setElementData() and getElementData() -- for transferring the textures from client to client
  11. addCommandHandler("ban",function(player,_,target,time) local target = getPlayerFromName(target) dbExec(--[[connection_handler]],"INSERT INTO `table` (`serial`,`timestamp`) VALUES (?,?);",getPlayerSerial(target),getRealTime()["timestamp"]+time) kickPlayer(target,player,string.format("You have been banned for %d seconds.",time)) end) addEventHandler("onPlayerJoin",root,function() local serial = getPlayerSerial(source) local data = dbPoll(dbQuery(--[[connection_handler]],"SELECT COUNT(*) AS 'count' FROM `table` WHERE `serial`=?;",serial),-1) if #data[1]["count"] ~= 0 then data = dbPoll(dbQuery(--[[connection_handler]],"SELECT `timestamp` FROM `table` WHERE `serial`=?;",serial),-1) if getRealTime()["timestamp"]>=data[1]["timestamp"] then dbExec(--[[connection_handler]],"DELETE FROM `table` WHERE `serial`=?",serial) else kickPlayer(source,"Console","You are temp-banned!") end end end) Just a basic example.
  12. cheez3d

    Small problem

    local language_handler = function(player,_,...) local text = table.concat({...}," ") local language = guiComboBoxGetItemText(LanguageWindow,guiComboBoxGetSelected(LanguageWindow)) outputChatBox("["..language.."] "..getPlayerName(localPlayer)..": "..text,root,255,255,255,true) end addCommandHandler("language",language_handler) bindKey("l","down","chatbox","language")
  13. GUIEditor.window[1] = guiCreateWindow(166, 127, 540, 359, "lock", false) GUIEditor.button[1] = guiCreateButton(311, 254, 162, 19, "lock", false, GUIEditor.window[1]) addEventHandler("onClientGUIClick",GUIEditor.button[1],function() triggerServerEvent("onPlayerRequestLock",localPlayer) end,false) addEvent("onPlayerRequestLock",true) addEventHandler("onPlayerRequestLock",root,function() local vehicle = getPedOccupiedVehicle(client) if vehicle then setVehicleLocked(vehicle,not isVehicleLocked(vehicle)) else outputChatBox("You are not inside a vehicle!",client) end end)
  14. for _,player in ipairs(getElementsByType("player")) do -- your code for every player, use the player variable end
  15. After I looked into the code several times I realised that I was adding the event handler every time the player pressed the button and that's why it got triggered more and more times per press. Problem solved!
  16. You can use pairs and ipairs for looping. http://lua-users.org/wiki/ForTutorial - look at the iterators section
  17. I forgot to add the attempts part. I edited the first post. I just decrease the attempts variable by one every time an invalid password is entered. But it modifies like this: First button press: 5-1 => 4 (function gets triggered 1 time) Second button press: 4-1 and then 3-1 => 2 (function gets triggered 2 times) Third button press: 2-1 and then 1-1 and then 0-1 => -1 (function gets triggered 3 times)
  18. I have a problem. I wanted to create a little anti spam filter. If the player fails to login 5 times then he will be kicked, but the problem is that the clientside function executes more than one time and I don't get kicked after 5 invalid attempts, but 3 invalid attempts. Everything else is explained in the script. Any help is appreciated . SERVER SIDE EVENT (where we check the data): addEventHandler("dayz:onPlayerRequestLogin",root,function(password) if password then local data = dbPoll(dbQuery(getElementData(resourceRoot,"dayz:resource.settings.database"),"SELECT `password` FROM `players` WHERE `serial`=?;",string.lower(getPlayerSerial(client))),-1) if data then if data[1]["password"] then if string.lower(md5(password)) == data[1]["password"] then triggerClientEvent(client,"dayz:onClientPlayerRequestLogin",client,true) -- password is correct else local event = triggerClientEvent(client,"dayz:onClientPlayerRequestLogin",client,false) -- password isn't correct outputChatBox(tostring(event),root) -- wanted to check if the problem is here, but it is not here, the event get's triggered just one time per button press end end end end end) CLIENT SIDE EVENT (this piece gets executed when the player presses a button). triggerServerEvent("dayz:onPlayerRequestLogin",localPlayer,guiGetText(content.box)) -- send data to server addEventHandler("dayz:onClientPlayerRequestLogin",localPlayer,function(result) -- server returns the result inside this function local attempts = 5 if result then -- if the password hashes are identical register_window:destroy("fade_out") register_window = nil elseif not result then -- if they're not identical outputChatBox("event triggered") -- this is where the problem is, this messages will output at the first press once, the at the second press twice, at the third press three times, and so on... what could be the problem? attempts = attempts -1 guiSetText(content.output,string.format("Invalid password! Use the %s button for recovery. You have %d attempts left.","Recover",attempts)) guiSetText(content.box,"") guiSetPosition(content.button_login.skeleton,(width-305)/2,(height-50)-25,false) if not content.button_recover then content.button_recover = GUI.Button.Normal:create((width-305)/2+155,(height-50)-25,150,50,"Recover",30,true,{91,91,91},{28,28,28},{156,156,156},function() outputChatBox("UNDER CONSTRUCTION") end,content.skeleton) end if attempts<=0 then triggerServerEvent("dayz:onPlayerTriggerLeave",localPlayer,"Console","You exceed the maximum login attempts",300) end end end)
  19. Does it return nil anywhere? Also note that your query is vulnerable to injections. Use question marks. local query = dbQuery(connection, "SELECT * FROM wcf1_user WHERE username = ?",account)
  20. function vehicleCreat( player, preis,vId) local account = tostring(getElementData ( source, "username" )) if connection then local query = dbQuery(connection, "SELECT * FROM wcf1_user WHERE username = '"..account.."'") local result = dbPoll(query,-1) for _,t in ipairs(result) do for k,v in pairs(t) do outputChatBox(tostring(t).." -> index: "..tostring(k).." -> value: "..tostring(v),root) end end end end addEvent( "CarBuy", true ) addEventHandler( "CarBuy", root, vehicleCreat ) Use this and post what it returns.
  21. addCommandHandler("redirect",function(player) redirectPlayer(player,"192.168.1.64",22003) end)
  22. Try these: tl=en-au tl=en-cc tl=en-gb tl=en-us
  23. Can you post the XML code?
×
×
  • Create New...