Jump to content

LabiVila

Members
  • Posts

    272
  • Joined

  • Last visited

Everything posted by LabiVila

  1. It actually doesn't. However, fixed, thanks anyway
  2. local x,y = guiGetScreenSize () function looting () for k,v in pairs (getElementsByType ("object")) do if getElementModel (v) == 2991 then local px, py, pz = getElementPosition (localPlayer) local ox, oy, oz = getElementPosition (v) dis = getDistanceBetweenPoints3D (px, py, pz, ox, oy, oz) if dis < 3 then dxDrawText ("You can loot the item, hold R.", x/3, y/3, x, y, tocolor (255, 255, 255, 255)) addEventHandler ("onClientKey", root, function (button, release) if button == "R" and release then outputChatBox ("R has been typed, ...") end end ) end end end end addEventHandler ("onClientRender", root, looting) The message "R has been typed, ..." isn't working, I'd appreciate some help.
  3. https://wiki.multitheftauto.com/wiki/Gu ... lectedItem - use this one to get the clickable item and you can manage the rest I think
  4. for a mighty price...
  5. Would you mind giving me the commands as I never did that before
  6. Yea I've actually done that one time, that's the way I got the distance to the marker (in meters), but I was told there's a way to put the players on a table then loop through it, but not sure how to...
  7. Cool, thanks mate, now there's no error
  8. function speed () if isPedInVehicle (localPlayer) then speedX, speedY, speedZ = getElementVelocity (getPedOccupiedVehicle (localPlayer)) speed = math.ceil (((speedX^2 + speedY^2 + speedZ^2)^(0.5))*180) dxDrawText (speed.." km/h", x/1.20, y/2.8, x, y, tocolor (255, 255, 255)) end end addEventHandler ("onClientRender", root, speed) WARNING: test\client:73: Bad argument @ 'getElementVelocity' ERROR: test\client:74: attempt to perform arithmetic on global "speedX" (a boolean value) It works but why do these message appear? and how can I fix them?
  9. Hey guys, if I've got a distance to a marker script, how can I get the top three closest players to that marker? I mean for example if I've got only 20 meters left (less than any other player), the dxDrawText shows: 1. LabiVila, 2. ..., 3. ..., you know? Where player "2" and player "3" have got less meters to go than the rest?
  10. I sadly can't, I'm not an advanced scripter, just a beginner, srry.
  11. function timePassed () if not systemUpTime then systemUpTime = getTickCount () end current = getTickCount () local res = math.floor((current - systemUpTime)/1000) dxDrawText (res, x/3, y/3, x, y, tocolor (255, 255, 255, 255), 1.5, "clear") addEventHandler ("onClientMarkerHit", getRootElement(), function () outputChatBox (getPlayerName (localPlayer).." has finished the map in: "..res.." mins.", source) end ) end addEventHandler ("onClientRender", getRootElement(), timePassed) the problem is that there is not just one outputChatBox like: mysticguy has won the map in .. minutes, but there are a lot of those like this: http://www.upload.ee/image/4249449/sss.png
  12. Not sure what you mean with Nemesis, I don't know what that word word means at all if you explain better, maybe I can help you out
  13. Hey, a progress bar isn't the best solution, this is a script which shows Health bar and Nitro Bar. It has an ugly appearance but the script is very simple and easy to understand. It's not a guiProgressBar tho, it's dx... just copy and paste it client-side and it'll work... local x,y = guiGetScreenSize () addEventHandler ("onClientRender", root, function (source) local pVehicle = getPedOccupiedVehicle (localPlayer) if pVehicle then local vHealth = (getElementHealth (pVehicle)-250)/10 if vHealth < 0 then vHealth = 0 end dxDrawLine (x/1.05, y/2.1, x/1.05, y/2.40, tocolor (255, 255, 255)) -- VER (HP) dxDrawLine (x/1.25, y/2.1, x/1.25, y/2.40, tocolor (255, 255, 255)) -- VER (HP) dxDrawLine (x/1.05, y/2.1, x/1.25, y/2.1, tocolor (255, 255, 255)) -- HOR (HP) dxDrawLine (x/1.05, y/2.4, x/1.25, y/2.4, tocolor (255, 255, 255)) -- HOR (HP) dxDrawRectangle (x/1.249, y/2.39,x/4.95*vHealth/100, y/17.25, tocolor (0, 255, 0, 175)) -- ARENA (HP) dxDrawText ("HP", x/1.163, y/2.35, x, y, tocolor (255, 255, 255, 200), 1.5, "clear") -- TEXT (HP) end end ) function drawNitroCopertine (source) dxDrawLine (x/1.05, y/1.7, x/1.05, y/1.9, tocolor (255, 255, 255)) -- VER (NOS) dxDrawLine (x/1.25, y/1.7, x/1.25, y/1.9, tocolor (255, 255, 255)) -- VER (NOS) dxDrawLine (x/1.05, y/1.7, x/1.25, y/1.7, tocolor (255, 255, 255)) -- HOR (NOS) dxDrawLine (x/1.05, y/1.9, x/1.25, y/1.9, tocolor (255, 255, 255)) -- HOR (NOS) dxDrawText ("NOS", x/1.173, y/1.86, x, y, tocolor (255, 255, 255, 200), 1.5, "clear") -- TEXT (NOS) end addEventHandler ("onClientRender", root, function (source) local pVehicle = getPedOccupiedVehicle (localPlayer) if pVehicle then drawNitroCopertine () local vNitro = getVehicleNitroLevel (pVehicle) if vNitro ~= nil and vNitro ~= false and vNitro > 0 then dxDrawRectangle (x/1.24902, y/1.8902, x/6.6/10*10*vNitro, y/16.75, tocolor (0, 175, 255, 175)) end end end )
  14. I know I'm looking for too much already but would you mind doing a small preview of it? I actually can't use proper setElementData nor getElementData..
  15. Tried that already Sam but didn't work, Ilyama, how can manage to create those in client-side then? or is it possible any other way of passing those two arguments to client side?
  16. I actually don't need to set them as zero because I already have them at the server-side as arguments but just can't put them like: function text (betted, amount) dxDrawText ("asd"..betted, x/3... end I wanna make it like this
  17. Hey guys, can you help me how to pass the two arguments betted and amount? And a small explanation would do the job (check line 75 and down at client side) (check line 55 at server side) --client side local x,y = guiGetScreenSize () function betplaced () dxDrawRectangle (x/1.6, y/3.125, x/3.25, y/15, tocolor (0, 0, 0, 150)) dxDrawText ("You have already placed a bet.", x/1.525, y/2.95, x, y, tocolor (255, 255, 255), 1, "clear") end addEvent ("alreadyPlaced", true) addEventHandler ("alreadyPlaced", root, function () addEventHandler ("onClientRender", root, betplaced) setTimer ( function () removeEventHandler ("onClientRender", root, betplaced) end , 5000, 1 ) end ) function Mnumber () dxDrawRectangle (x/1.6, y/3.125, x/3.25, y/15, tocolor (0, 0, 0, 150)) dxDrawText ("The value must be a number.", x/1.525, y/2.95, x, y, tocolor (255, 255, 255), 1, "clear") end addEvent ("number", true) addEventHandler ("number", root, function () addEventHandler ("onClientRender", root, Mnumber) setTimer ( function () removeEventHandler ("onClientRender", root, Mnumber) end , 5000, 1 ) end ) function moneymissing () dxDrawRectangle (x/1.6, y/3.125, x/3.25, y/15, tocolor (0, 0, 0, 150)) dxDrawText ("You don't have enough money.", x/1.525, y/2.95, x, y, tocolor (255, 255, 255), 1, "clear") end addEvent ("noMoney", true) addEventHandler ("noMoney", root, function () addEventHandler ("onClientRender", root, moneymissing) setTimer ( function () removeEventHandler ("onClientRender", root, moneymissing) end , 5000, 1 ) end ) function notfound () dxDrawRectangle (x/1.6, y/3.125, x/3.25, y/15, tocolor (0, 0, 0, 150)) dxDrawText ("The player wasn't found.", x/1.525, y/2.95, x, y, tocolor (255, 255, 255), 1, "clear") end addEvent ("noFound", true) addEventHandler ("noFound", root, function () addEventHandler ("onClientRender", root, notfound) setTimer ( function () removeEventHandler ("onClientRender", root, notfound) end , 5000, 1 ) end ) function text (betted, amount) dxDrawText ("asd", x/3, y/3, x, y, tocolor (255, 255, 255)) end addEvent ("betPlaced", true) addEventHandler ("betPlaced", root, function () addEventHandler ("onClientRender", root, text) setTimer ( function () removeEventHandler ("onClientRender", root, text) end , 5000, 1 ) end ) --server side function onPlayerQuit () local playeraccount = getPlayerAccount (source) if (playeraccount) and not isGuestAccount (playeraccount) then local playermoney = getPlayerMoney (source) setAccountData (playeraccount, "piraterpg.money", playermoney) end end addEventHandler ("onPlayerQuit", getRootElement(), onPlayerQuit) function onPlayerLogin (_, playeraccount) if (playeraccount) then local playermoney = getAccountData (playeraccount, "piraterpg.money") if (playermoney) then setPlayerMoney (source, playermoney) end end end addEventHandler ("onPlayerLogin", getRootElement(), onPlayerLogin) function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end bets = {} function bet (source, cmd, betted, amount) local a = tonumber (amount) local betted = getPlayerFromPartialName (betted) if (bets [source]) then return triggerClientEvent (source, "alreadyPlaced", source) -- bet already placed end if (not a) then return triggerClientEvent (source, "number", source) -- must be number end if (getPlayerMoney (source) < a ) then return triggerClientEvent (source, "noMoney", source) -- insufficient money amount end if (not betted) then return triggerClientEvent (source, "noFound", source) -- player wasn't found end bets [source] = {player = betted,amount = amount} triggerClientEvent (source, "betPlaced", source, betted, amount) takePlayerMoney (source, amount) end function removeCmd (state) if (state == "Running") then outputChatBox ("[bET] Bets have been closed!", getRootElement(), 255, 255, 255) removeCommandHandler ("bet", bet) end end addEvent ("onRaceStateChanging") addEventHandler ("onRaceStateChanging", getRootElement(), removeCmd) function addCmd () local alivePlayers = getAlivePlayers () if #alivePlayers >= 1 then outputChatBox ("[bET] Place bets now by typing /bet [playername] [money]", getRootElement(), 255, 255, 255) addCommandHandler ("bet", bet) else outputChatBox ("[bET] At least 5 players are needed to use bet.", getRootElement(), 255, 255, 255) removeEventHandler ("onRaceStateChanging", getRootElement(), removeCmd) end end addEvent ( "onGamemodeMapStart", true ) addEventHandler ("onGamemodeMapStart", getRootElement(), addCmd) function winner () for i, v in pairs ( bets ) do if ( isElement ( i ) ) then if ( source == v.player ) then givePlayerMoney ( i, v.amount * 2 ) outputChatBox ("[bET] "..getPlayerName (localPlayer).." won a bet on "..getPlayerName (source)..".", getRootElement(), 255, 255, 255, i) else outputChatBox ("[bET] You lost your bet on"..getPlayerName (source).."!", source, 255, 255, 255) end end end bets = {} end addEvent ("onPlayerWinDD", true) addEventHandler ("onPlayerWinDD", getRootElement(), winner)
  18. As said up, this is my very first time doing this so I'd really like an example as I can't make it work...
  19. Calling my players nab is just a test, to see if it's working... I'll surely edit that later. This script is about some daily rewards, once you hit 10 hunters, you get some money (as you see in the script). I'll make this panel reset every 24 hour, but when a player quits and comes again, players are actually 0, they should be the same number as when they quit... hopefully you got what I'm trying to do.
  20. Can you give me an example? It's the very first time I'm doing this so... it's a bit hard for me
  21. function onPlayerQuit () playeraccount = getPlayerAccount (source) if (playeraccount) and not isGuestAccount (playeraccount) then local playermoney = getPlayerMoney (source) setAccountData (playeraccount, "piraterpg.money", playermoney) end end addEventHandler ("onPlayerQuit", getRootElement(getThisResource()), onPlayerQuit) function onPlayerLogin (_, playeraccount) if (playeraccount) then local playermoney = getAccountData (playeraccount, "piraterpg.money") if (playermoney) then setPlayerMoney (source, playermoney) end end end addEventHandler ("onPlayerLogin", getRootElement(), onPlayerLogin) ------------------------------------------------------------------------------------- local hunters = 0 local deaths = 0 local starts = 0 function hunterPickups (pickupID, pickupType, vehicleModel) local playeraccount = getPlayerAccount (source) if (playeraccount) and not isGuestAccount (playeraccount) then if pickupType == "vehiclechange" and vehicleModel == 425 then outputChatBox ("one more hunter", source) hunters = hunters + 1 triggerClientEvent (source, "hunterADD", source, hunters) if hunters == 10 then removeEventHandler ("onPlayerPickUpRacePickup", root, hunterPickups) givePlayerMoney (source, 7500) end end else outputChatBox ("You must be logged in... nab", source) end end addEventHandler ("onPlayerPickUpRacePickup", root, hunterPickups) function deathADD () local playeraccount = getPlayerAccount (source) if (playeraccount) and not isGuestAccount (playeraccount) then deaths = deaths + 1 triggerClientEvent (source, "deathADD", source, deaths) if deaths == 25 then removeEventHandler ("onPlayerRaceWasted", root, addDeath) givePlayerMoney (source, 7500) end else outputChatBox ("You must be logged in fcker", source) end end addEvent ("onPlayerRaceWasted", true) addEventHandler ("onPlayerRaceWasted", root, deathADD) function addStartPoint (state) local playeraccount = getPlayerAccount (source) if (playeraccount) and not isGuestAccount (playeraccount) then if (state == "Running") then starts = starts + 1 triggerClientEvent (source, "startADD", source, starts) if starts == 25 then removeEventHandler ("onRaceStateChanging", root, addStartPoint) givePlayerMoney (source, 7500) end end else outputChatBox ("You must be logged in, LOGGED IN!", source) end end addEvent ("onRaceStateChanging", true) addEventHandler ("onRaceStateChanging", root, addStartPoint) Hello, this is my code, and it works cool. But there is something I need to know and haven't ever done it before, if we cut this part: function hunterPickups (pickupID, pickupType, vehicleModel) local playeraccount = getPlayerAccount (source) if (playeraccount) and not isGuestAccount (playeraccount) then if pickupType == "vehiclechange" and vehicleModel == 425 then outputChatBox ("one more hunter", source) hunters = hunters + 1 triggerClientEvent (source, "hunterADD", source, hunters) if hunters == 10 then removeEventHandler ("onPlayerPickUpRacePickup", root, hunterPickups) givePlayerMoney (source, 7500) end end else outputChatBox ("You must be logged in... nab", source) end end addEventHandler ("onPlayerPickUpRacePickup", root, hunterPickups) how am I possible to do that when the player quits, the hunters = hunters + 1 store on his account, and when he gets back, he has the same hunters amount? Thanks further
  22. Done, thank you so much EDIT: even tho I didn't quiet understand your answer
  23. Tried already, didn't work...
  24. Hello over and over again; --client local x,y = guiGetScreenSize () function dailyShits () dxDrawRectangle (x/1.65, y/5, x/3, y/5, tocolor (0, 0, 0, 150)) dxDrawText ("Daily Rewards:", x/1.6, y/4.65, x, y, tocolor (255, 255, 255, 255), 1.25, "clear") dxDrawText ("1. Get 10 hunters", x/1.6, y/3.8, x, y, tocolor (255, 255, 255, 255), 1, "clear") dxDrawText ("2. Win 10 maps", x/1.6, y/3.3, x, y, tocolor (255, 255, 255, 255), 1, "clear") end addEventHandler ("onClientRender", root, dailyShits) function addPoint (hunters) addEventHandler ("onClientPreRender", root, function () dxDrawText (hunters.."/10", x/3, y/3, x, y, tocolor (0, 0, 0, 150), 7, "clear") end ) end addEvent ("hunterADD", true) addEventHandler ("hunterADD", root, addPoint) --server local hunters = 0 function hunterPickups (pickupID, pickupType, vehicleModel) if pickupType == "vehiclechange" and vehicleModel == 425 then outputChatBox ("one more hunter", source) hunters = hunters + 1 triggerClientEvent (source, "hunterADD", source, hunters) end end addEventHandler ("onPlayerPickUpRacePickup", root, hunterPickups) Everything works cool but something is wrong in dxDrawText (hunter....). Here's a screen of the "bug": http://gyazo.com/2c0d4ca9820324e3e5c57e043b08e2b5 and it must be like, 1 then 2 then 3.. and etc.
×
×
  • Create New...