itHyperoX
Members-
Posts
522 -
Joined
-
Last visited
-
Days Won
1
Everything posted by itHyperoX
-
Hi! I just started learning mysql. So my problem is, i can save the player's weapon's, but when player die, the weapons just disappearing. I downloaded a script from the community, which is saving weapons to *setAccountData*, and i want to use this with mysql. -- I want to use something like this local Account = mysql:singleQuery("SELECT * FROM accounts WHERE AccountID=?, Weapons=? LIMIT 1", getElementData(source, "Player:AccountID")) addEventHandler("onPlayerSpawn",root,function () local account = getPlayerAccount(source) -- I don't know how to change this to mysql. if (account) and not (isGuestAccount(account)) then local weapons = getAccountData(account, "PlayerAccount:Weapons") -- I don't know how to change this to mysql. if (weapons) and (fromJSON(weapons)) then takeAllWeapons(source) for weapon, ammo in pairs(fromJSON(weapons)) do giveWeapon(source, weapon, ammo, true) end end end end) addEventHandler("onPlayerWasted",root,function () local account = getPlayerAccount(source) -- I don't know how to change this to mysql. if (account) and not (isGuestAccount(account)) then local weapons = getAllPedWeapon(source) setAccountData(account, "PlayerAccount:Weapons", toJSON(weapons)) end end) addEventHandler("onResourceStart",resourceRoot,function (resource) for _, thePlayer in pairs(getElementsByType("player")) do local account = getPlayerAccount(thePlayer) if (account) and not (isGuestAccount(account)) then triggerEvent("loadPlayerDatas", thePlayer, account) end end end) addEventHandler("onPlayerQuit",root,function () local account = getPlayerAccount(source) if (account) and not (isGuestAccount(account)) then triggerEvent("savePlayerDatas", source, account) end end) addEventHandler("onResourceStop",resourceRoot,function (resource) for _, thePlayer in pairs(getElementsByType("player")) do local account = getPlayerAccount(thePlayer) if (account) and not (isGuestAccount(account)) then triggerEvent("savePlayerDatas", thePlayer, account) end end end) function getAllPedWeapon(thePed) local weapons = { } for slot=1, 12 do local weapon = getPedWeapon(thePed, slot) local ammo = getPedTotalAmmo(thePed, slot) if (weapon > 0) and (ammo > 0) then weapons[weapon] = ammo end end return weapons end
-
Can the third lua script cancel event(onResourceStart) from server-side script or not? no.
-
Right, now i don't get any error, but now sometimes the cursor is not hiding. Fixed, thanks.
-
Hi, i found this dxlib on the community, i'm working on a weapon shop, when i destroy the dxEditBox, then i reopen, i'm only getting erros. I tried to fix it myself, and i still don't know whats the problem. Debugs: line 19: onClientKey with this function is already handled line 20: onClientCharacter with this function is already handled. Code: function dxCreateEdit(x, y, w, h, text, icon, lenght, r, g, b, alpha, mask, postGUI) local theEdit = createElement("dxEdit") if getn(edit.data) < 1 then addEventHandler("onClientCharacter", getRootElement(), addCharacterToEdit) -- line 19 addEventHandler("onClientKey", root, backspace) -- line 20 end edit.data[theEdit] = {x = x, y = y ,w = w, h = h, dt = text, icon = icon, ml = lenght, r = r or 0, g = g or 0,b = b or 0, alpha = alpha or 150, mask = mask or false, postGUI = postGUI or false, text = "" , clicked = false, selectAll = false, enabled = true} return theEdit end function addCharacterToEdit(character) if character == " " then return end if string.byte(character) < 32 or string.byte(character) > 127 then return end local Edit = getElementsByType("dxEdit") for i=1,#Edit do if edit.data[Edit[i]] then if edit.data[Edit[i]].clicked == true then if edit.data[Edit[i]].selectAll == true then edit.data[Edit[i]].selectAll = false edit.data[Edit[i]].text = "" end if edit.data[Edit[i]].ml ~= nil then if #edit.data[Edit[i]].text < edit.data[Edit[i]].ml then edit.data[Edit[i]].text = edit.data[Edit[i]].text..character end else edit.data[Edit[i]].text = edit.data[Edit[i]].text..character end end end end end function backspace(key,sm) if sm then local Edit = getElementsByType("dxEdit") for i=1,#Edit do if edit.data[Edit[i]] then if edit.data[Edit[i]].clicked == true then if string.len(edit.data[Edit[i]].text) > 0 and key == "backspace" then if edit.data[Edit[i]].selectAll == false then edit.data[Edit[i]].text = string.sub(edit.data[Edit[i]].text,1,string.len(edit.data[Edit[i]].text)-1) else edit.data[Edit[i]].selectAll = false edit.data[Edit[i]].text = "" end elseif getKeyState("lctrl") and key == "a" or getKeyState("rctrl") and key == "a" then edit.data[Edit[i]].selectAll = not edit.data[Edit[i]].selectAll end end end end end end
-
I'm already tried this. Not working.
-
I already tried. function playerPressedKey(button, press) if (press) then -- Only output when they press it down if (button == "arrow_l") or (button == "arrow_r") then cancelEvent() print("blocked") end end end addEventHandler("onClientKey", root, playerPressedKey)
-
Hi, is there anyway to cancel the arrow_l , arrow_r when player typed on guiCreateEdit ?
-
https://wiki.multitheftauto.com/wiki/SetHelicopterRotorSpeed
-
getTickCount or setTimer
-
If you really want it send me a pm and i'll make my own for you.
-
function spawn( player ) if not (getElementData(player, "player:warped") == true) then local rnd = math.random( 1, #spawns ) setElementPosition( player, spawns[rnd][1], spawns[rnd][2], spawns[rnd][3] ) setElementData(player, "player:warped", true) end end addCommandHandler("pvp",spawn)
-
use this dxDrawRectangleBox(x*447, y*615, x*235/100, y*21, math.floor(getElementHealth(localPlayer)), tocolor(0, 0, 0, 150)) function dxDrawRectangleBox(startX, startY, sizeX, sizeY, playerStat, color) dxDrawRectangle(startX, startY, sizeX, sizeY, tocolor(107, 107, 107, 180)) --box dxDrawRectangle(startX-2, startY-2, 2, sizeY+4, tocolor(0, 0, 0, 220)) --left dxDrawRectangle(startX+sizeX, startY-2, 2, sizeY+4, tocolor(0, 0, 0, 220)) --right dxDrawRectangle(startX, startY-2, sizeX, 2, tocolor(0, 0, 0, 220)) --up dxDrawRectangle(startX, startY+sizeY, sizeX, 2, tocolor(0, 0, 0, 220)) --down dxDrawRectangle(startX, startY, sizeX/100*playerStat, sizeY, color) --stat end
-
try this: -- command for set you as leader addCommandHandler("leader", function() setElementData(localPlayer, "team:leader", true) end) addEventHandler("onClientGUIClick", guiRoot, function() if (getElementData(localPlayer, "team:leader") == true) then iprint("I'm a leader!") if source == GUIEditor.button[3] then local row, column = guiGridListGetSelectedItem( GUIEditor.gridlist[1]) if (row ~= - 1) then local playerName = guiGridListGetItemText( GUIEditor.gridlist[1],row,column) local player = getPlayerFromName(playerName) local team = getPlayerTeam(localPlayer) local teamName = getTeamName(team) if not playerName then return guiGridListRemoveRow(row) end triggerServerEvent("Add to team", localPlayer, playerName, teamName) end end end end)
-
Are you saving it? if not, you have to save it. local phoneNumber = getElementData(thePlayer, "Phone") if phoneNumber then setAccountData(getPlayerAccount(thePlayer), "playerAccount:Phone", phoneNumber) end --then load it when player login. local phoneNumber = getAccountData(getPlayerAccount(thePlayer), "playerAccount:Phone") if phoneNumber then setElementData(thePlayer, "Phone", tonumber(phoneNumber)) end
-
feel free to edit. --< [ /mute ] >-- local playerMuteTimer = {} function insertToPlayerAccount(player, data, value) return setAccountData(getPlayerAccount(player), data, value) end function getFromPlayerAccount(player, data) return getAccountData(getPlayerAccount(player), data) end --< [ Info ] >-- addCommandHandler("muteinfo", function(player,cmd) if isPlayerMuted(player) then outputChatBox(core:getSyntax("warning").." Némítva vagy még "..math.ceil(getTimerDetails(playerMuteTimer[player])/60000).." percig.", player, 255, 255, 255, true) else outputErrorMSG("Nem vagy némítva!", player) end end) --< [ Kilépés ] >-- addEventHandler("onPlayerQuit", root, function() if isTimer(playerMuteTimer[source]) then outputChatBox("#FB5555[Offline Némítás]:#00B4FF "..getPlayerName(source).."#FFFFFF némítva lett a rendszer által "..math.ceil(getTimerDetails(playerMuteTimer[source])/60000).." percre.", root, 255, 0, 0, true) insertToPlayerAccount(source, "account#muted", math.ceil(getTimerDetails(playerMuteTimer[source])/60000)) killTimer(playerMuteTimer[source]) end end) --< [ Bejelentkezés ] >-- addEventHandler("onPlayerLogin", root,function() local playerMuted = getFromPlayerAccount(source, "account#muted") if not playerMuted then return end if (playerMuted >= 0) then setPlayerMuted(source, true) setElementData(source, "char#muted", 1) playerMuteTimer[source] = setTimer(function() setPlayerMuted(source,false) outputChatBox("#FB5555[Némítás]:#00B4FF "..getPlayerName(source).."#FFFFFF némítása lejárt.", root, 255, 0, 0, true) insertToPlayerAccount(source, "account#muted", 0) removeElementData(source, "char#muted") end,playerMuted*60000,1) outputChatBox(core:getSyntax("warning").." Némítva vagy még "..math.ceil(getTimerDetails(playerMuteTimer[source])/60000).." percre.", source, 255, 255, 255, true) end end)
-
You can't edit planes / helicopters handling's.
-
Nah.
- 7 replies
-
- object limiter
- adding
-
(and 3 more)
Tagged with:
-
setTimer(function() local hunger = getElementData(localPlayer, "hunger") setElementData(localPlayer, "hunger", hunger - 5) end, 30000, 0)
-
I think you can replace an object dff then attach the object to the hydra. I think there is no other way.
-
english pls
-
you don't need onClientResourceStart when you use onClientRender. just addEventHandler("onClientRender", root, function() --- Your code here. onStart() end) And if you want to something with player when they join, just use this: function onStart() showCursor(true) showChat(false) end