Jump to content

Citizen

Moderators
  • Posts

    1,803
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by Citizen

  1. That code works just fine: and Please make sure you did everything correctly before saying it doesn't work. Most of the scripters here do not test the scripts, they are guessing the problem and the solutions using what the original poster says and their knowledges. As I can see you are french, if you prefer, you can ask for help in french in the French subforum. I saw you were kinda angry because you didn't get a reply in time because I'm kinda alone in that section and I was away from home. I always watch that French section and I get an email notification for each thread created in that section. I hope to see you again there: viewforum.php?f=128 Best regards, Citizen
  2. Any error on the client-side ? In general if you have this error: Then it means that the function doesn't exist or is not defined yet. Make sure you have copied and pasted the dxDrawCircle function at the right place.
  3. As setGravitywon't affect ped/players, you have to use setPedGravityinstead, but this function is available on the server side only. So you have to do this on the server-side obviously: setTimer(function () for k, player in ipairs ( getElementsByType( "player" ) ) do -- for all connected players local _, _, z = getElementPosition( player ) -- get his position ( we just care about the z position ) if z >= 1000 then -- if the player's z position is over or equal to 1000 setPedGravity( player, 0.001 ) -- lower his gravity to 0.001 else -- otherwise setPedGravity( player, 0.008 ) -- set his gravity to default one end end end, 1000, 0) -- and do the entire thing every seconds
  4. PM from the past week: I gave you an example on how to use my script ... Are you really trying to understand ? First get my script that adds the onPlayerTeamChange event and the marker for team visibility system: ------------------------------------- ---- /!\ DO NOT MODIFY BELOW /!\ ---- ------------------------------------- -- This function will get all blips that should be visible for a team and will show it for that entire team and will hide it for all others function updateTeamBlipsVisibility() -- DO NOT MODIFY for k, blip in ipairs(getElementsByType("blip")) do local blipTeam = getElementData(blip, "visibleForTeam") if blipTeam and getElementType(blipTeam) == "team" then clearElementVisibleTo(blip) -- reset the visibility settings for the blip setElementVisibleTo(blip, root, false) -- hide for everyone setBlipVisibleForTeam(blip, blipTeam) -- show for the entire team the blip is associated with end end end -- show a blip for all members of a given team element function setBlipVisibleForTeam(blip, team) -- DO NOT MODIFY for i, player in ipairs( getPlayersInTeam(team) ) do setElementVisibleTo(blip, player, true) end end ------- Logic for the onPlayerChangeTeam event ------- addEvent("onPlayerChangeTeam", true) local _playersTeamCache = {} function onPlayerChangeTeamWatcher() -- DO NOT MODIFY for i, player in ipairs(getElementsByType("player")) do local pTeam = getPlayerTeam(player) local oldTeam = _playersTeamCache[player] or false if pTeam and pTeam ~= oldTeam then -- If he changed team triggerEvent("onPlayerChangeTeam", player, oldTeam, pTeam) _playersTeamCache[player] = pTeam end end end setTimer(onPlayerChangeTeamWatcher, 600, 0) --[[ you can change the "sensibility" of the team change detection: the lower the timer is, the faster the event will be triggered but it can produces lags on a big amount of players and blips ]] addEventHandler("onPlayerQuit", root, function () _playersTeamCache[source] = nil end) ------------------------------------------------------ -- You can modify below Then just do like my example: So in your case: local criminalTheftBlip = createBlipAttachedTo(crimainlTheftVehicle, 12) -- 1: create the blip as usual setElementData(criminalTheftBlip, "visibleForTeam", getTeamFromName("Criminal")) -- 2: says for which team this blip will be visible for updateTeamBlipsVisibility() -- 3: call an entire refresh -- 4: do whatever you want (here the message for all Criminals) for i, player in ipairs(getPlayersInTeam(getTeamFromName("Criminal"))) do exports['msg']:sendMessage("Car Jacker: There is a car to steal, go pickup it up.", player,238, 44, 44) end See ? it wasn't that hard to use my code for what you wanted to do. Best regards, Citizen There is no errors and it's working fine on my side. Read the error again carefully and find where is the error located at. By the way I tested it again and just realised I forgot to call the updateTeamBlipsVisibility() function when a player joined another team. So here is the backend code again: And PLEASE ! DO NOT MODIFY THE FOLLOWING CODE (except for the milliseconds of the infinite timer). ------------------------------------- ---- /!\ DO NOT MODIFY BELOW /!\ ---- ------------------------------------- ------- Logic for the onPlayerChangeTeam event ------- addEvent("onPlayerChangeTeam", true) local _playersTeamCache = {} function onPlayerChangeTeamWatcher() -- DO NOT MODIFY for i, player in ipairs(getElementsByType("player")) do local pTeam = getPlayerTeam(player) local oldTeam = _playersTeamCache[player] or false if pTeam and pTeam ~= oldTeam then -- If he changed team triggerEvent("onPlayerChangeTeam", player, oldTeam, pTeam) _playersTeamCache[player] = pTeam end end end setTimer(onPlayerChangeTeamWatcher, 600, 0) --[[ you can change the "sensibility" of the team change detection: the lower the timer is, the faster the event will be triggered but it can produces lags on a big amount of players and blips ]] addEventHandler("onPlayerQuit", root, function () _playersTeamCache[source] = nil end) ------------------------------------------------------ ----------- Logic for the team blips system ---------- -- This function will get all blips that should be visible for a team and will show it for that entire team and will hide it for all others function updateTeamBlipsVisibility() -- DO NOT MODIFY for k, blip in ipairs(getElementsByType("blip")) do local blipTeam = getElementData(blip, "visibleForTeam") if blipTeam and getElementType(blipTeam) == "team" then clearElementVisibleTo(blip) -- reset the visibility settings for the blip setElementVisibleTo(blip, root, false) -- hide for everyone setBlipVisibleForTeam(blip, blipTeam) -- show for the entire team the blip is associated with end end end -- show a blip for an entire team it is associated with function setBlipVisibleForTeam(blip, team) -- DO NOT MODIFY for i, player in ipairs( getPlayersInTeam(team) ) do setElementVisibleTo(blip, player, true) end end addEventHandler("onPlayerChangeTeam", root, function () updateTeamBlipsVisibility() end) ---------------------------------------------------- And here is a test case for you to see it in action: => Test case code: createTeam("Criminals") createTeam("Cops") function addRandomBlip(thePlayer, cmd, teamName) local team = getTeamFromName(teamName) if team then local x, y = math.random(-2000, 2000), math.random(-2000, 2000) local blip = createBlip(x, y, 0) setElementData(blip, "visibleForTeam", team) updateTeamBlipsVisibility() end end addCommandHandler("blip", addRandomBlip, false, false) function changeTeam(thePlayer, cmd, teamName) local team = getTeamFromName(teamName) if team then setPlayerTeam(thePlayer, team) end end addCommandHandler("team", changeTeam, false, false) => Test case commands: When you are ingame us the test case as follow: 1 - /blip Criminals to add a random blip on the map for the Criminals team 2 - /blip Cops to add a random blip on the map for the Cops team 3 - /team Criminals to join the Criminals team (it will show you the blip you created at step 1) 4 - /team Cops to join the Cops team (it will hide the blip you created at step 1 and show you the blip you created at step 2 instead). I have tested it again, so if it's not working for you, then you did something wrong. It should also work with a createBlipAttachedTo, you just have to do the setElementData properly on the created blip, and call a refresh: setElementData(blip, "visibleForTeam", team) updateTeamBlipsVisibility() Regards, Citizen
  5. What is wrong with the use loadstring? You can give more information? You can just do this instead: if isVisible then Menu() else deMenu() end It's easier to read, and so, to maintain. It's faster that using the loadstring function. This loadstring function is a time consuming compared to a simple if - else statement. So it's not because that your code looks shorter than it is shorter to execute. So avoid using loadstring if you can do it another way, especially if it's used inside onClientRender or onClientPreRender, you can produce the FPS drops by doing "heavy" tasks in those events.
  6. Citizen

    Solved

    And where do you use the setElementData for "lang" ? Because we can see you are trying to GET it but you never explained/shown us how you set that element data.
  7. Ok from the fragments of code you provided, I think I guessed the steps: 1 - you show the gui to get user inputs 2 - then you triggerServerEvent to send the inputs with the "convertCurrency" event name. 3 - on the server-side the handler of that event will then call an api using fetchRemote. At this point the handler has access to the client variable that represents who triggered the "convertCurrency" event. 4 - the fetchRemote is executed and you receive the results in the callback function. At this point (so inside the callback function) you DO NOT have access to the client variable anymore. So you can't triggerClientEvent using the client variable as it doesn't exist anymore. If you want it inside your callback, you have to pass it to the callback aswell by adding client in the arguments list of the fetchRemote function. Then you will do your trigger on using that callback argument. If it's still not clear, show us your fetchRemote and the callback function. Regards, Citizen
  8. Citizen

    Unbind key

    Glad to hear that ! Have fun scripting
  9. Yeah, the logic was not really clear so I kinda wrote down exactly when the radio should be turned on and when it should be turned off. I wrote two seperate functions to turn it on and off, and then I just had to call them exactly when I wanted to. No problem
  10. Citizen

    Unbind key

    Are you using the setElementPosition function for the player ? If so, make sure you do not set the Z position too low. If you are sure it's not the problem, then it might be a streaming issue (objects that are far from the camera are "streamed out" for better performance, so the buildings, ground etc, are kinda unloaded) just freeze the player for 1 or 2 seconds to let the game enough time to reload the unloaded objects and then unfreeze him.
  11. Here is how your code should look like (read the comments): local radiomegy = false -- radio isn't playing function radiobekapcsol () if not radiomegy then -- if the radio is not playing then if isPedInVehicle (localPlayer) then -- if the local player is in a vehicle then playRadio() -- start the radio else outputChatBox("#8B1A1ANem vagy autóban!#8B1A1A", localPlayer, 255, 255, 255, true) end else -- if the radio is playing then stopRadio() -- stop the radio end end function playRadio() setSoundVolume(stream, 1) -- set the volume to 1 outputChatBox("#00FF00Bekapcsoltad a rádiót !#00FF00", localPlayer, 255, 255, 255, true) radiomegy = true -- the radio is started end function stopRadio() setSoundVolume(stream, 0) -- set the volume to 0 outputChatBox("#00FF00Kikapcsoltad a rádiót !#00FF00", localPlayer, 255, 255, 255, true) radiomegy = false -- the radio is stopped end addEventHandler("onClientPlayerVehicleExit", localPlayer, stopRadio) -- calls stopRadio after the local player exited a vehicle
  12. Citizen

    Solved..

    Did you paste the entire function ?? Because it's how it looks like in my Notepad++ if there is nothing to add after that in the function, just close it correctly: addEvent("onZombieKilled",true) addEventHandler("onZombieKilled", getRootElement(), function (killer) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(killer)), aclGetGroup("VIP")) then local points = math.random(1,10) givePlayerMoney(killer, points) if getElementData(localPlayer, "lang") == "EN" then if tonumber(points) == 1 or tonumber(points) == 0 then PointsString = "TEST" elseif tonumber(points) >= 2 and tonumber(points) <= 4 then PointsString = "TEST1" elseif tonumber(points) => 5 then PointsString = "TEST2" end outputChatBox("#FFFF00[VIP] #00FF00test #FF0000[" .. points .. "] #00FF00"..PointsString, killer, 255, 255, 255, true) elseif getElementData(localPlayer, "lang") == "EN2" then if tonumber(points) == 1 or tonumber(points) == 0 then PointsString = "TEST" elseif tonumber(points) >= 2 and tonumber(points) <= 4 then PointsString = "TEST1" elseif tonumber(points) => 5 then PointsString = "TEST2" end outputChatBox("#FFFF00[VIP] #00FF00test #FF0000[" .. points .. "] #00FF00"..PointsString, killer, 255, 255, 255, true) end end end) If it was the problem you should have seen errors in the server console you didn't mention. And please don't use notepad.exe, wordpad, Word etc, use Notepad++ or Sublime Text instead.
  13. You need to setSoundVolume(stream, 0) When the OnClientPlayerVehicleExit is triggered on the localPlayer. By the way I would turn off the stream instead of just setting its volume to 0.
  14. Citizen

    Solved..

    I don't know where you pasted my code so please show us the entire function.
  15. Citizen

    Unbind key

    Maybe you can try something cleaner like this: addEventHandler ("onClientGUIClick", root, function () if (source == cancel) then exitCamera() elseif (source == accept) then local row,col = guiGridListGetSelectedItem(camGrid) if row and col and row ~= -1 and col ~= -1 then guiSetVisible(window,false) showCursor(true) outputChatBox ("Camera: Press X to stop the camera.",0,255,0) local x = guiGridListGetItemText (camGrid, guiGridListGetSelectedItem (camGrid),3) local y = guiGridListGetItemText (camGrid, guiGridListGetSelectedItem (camGrid),4) local z = guiGridListGetItemText (camGrid, guiGridListGetSelectedItem (camGrid),5) local cx = guiGridListGetItemText (camGrid, guiGridListGetSelectedItem (camGrid),6) local cy = guiGridListGetItemText (camGrid, guiGridListGetSelectedItem (camGrid),7) local cz = guiGridListGetItemText (camGrid, guiGridListGetSelectedItem (camGrid),8) triggerServerEvent("Camera:watch",localPlayer,guiGridListGetSelectedItem(camGrid)+1) bindKey("X", "down", exitCamera) else outputChatBox ("Camera System: You didn't select the item.",0,180,23) end end end) function exitCamera() guiSetVisible(window, false) showCursor(false) unbindKey("X", "down", exitCamera) setCameraTarget(localPlayer) showChat(true) end Yyou were doing the unbindKey call only if the user clicked on the cancel button, but not when you pressed the "X" key See if it works like this.
  16. [quote name=..&G:..] triggerClientEvent ( getRootElement(), "showConversionResult", resourceRoot, from, to, tonumber ( amount ), results["rates"][to] ) Just replace getRootElement() by the player element you want to update his GUI. If you keep getRootElement() it will send that event to all connected players.
  17. It works just fine for me (just need some adjustments though): You need to: 1 - Download the bone_attach.zip and place it in your resources folder 2 - Start the bone_attach resource or you won't be able to use the exported functions. 3 - Use the code you just pasted in the previous post. You can add an tag in your meta to start the bone_attach resource automatically with your resource.
  18. Citizen

    Solved..

    Try somthing like this: if getElementData(localPlayer, "lang") == "EN" then if tonumber(points) == 1 or tonumber(points) == 0 then PointsString = "TEST" elseif tonumber(points) >= 2 and tonumber(points) <= 4 then PointsString = "TEST1" elseif tonumber(points) => 5 then PointsString = "TEST2" end outputChatBox("#FFFF00[VIP] #00FF00test #FF0000[" .. points .. "] #00FF00"..PointsString, killer, 255, 255, 255, true) elseif getElementData(localPlayer, "lang") == "FR" then if tonumber(points) == 1 or tonumber(points) == 0 then PointsString = "TEST" elseif tonumber(points) >= 2 and tonumber(points) <= 4 then PointsString = "TEST1" elseif tonumber(points) => 5 then PointsString = "TEST2" end outputChatBox("#FFFF00[VIP] #00FF00test #FF0000[" .. points .. "] #00FF00"..PointsString, killer, 255, 255, 255, true) end
  19. No problem Have fun coding !
  20. Try this instead: local button = getControl ( wndMain, "شخصيات" ) guiSetAlpha ( button, 0.0 ) local button2 = getControl ( wndMain, "إنتحار" ) guiSetAlpha ( button2, 0.0 ) local button3 = getControl ( wndMain, "حركات" ) guiSetAlpha ( button3, 0.0 ) local button4 = getControl ( wndMain, "ملابس" ) guiSetAlpha ( button4, 0.0 ) local button5 = getControl ( wndMain, "أدوات" ) guiSetAlpha ( button5, 0.0 ) local button6 = getControl ( wndMain, "إنتقال" ) guiSetAlpha ( button6, 0.0 ) local button7 = getControl ( wndMain, "حفظ المكان" ) guiSetAlpha ( button7, 0.0 ) local button8 = getControl ( wndMain, "playergrav" ) guiSetAlpha ( button8, 0.0 ) local button9 = getControl ( wndMain, "الحالة" ) guiSetAlpha ( button9, 0.0 ) local button10 = getControl ( wndMain, "setpos" ) guiSetAlpha ( button10, 0.0 ) local button11 = getControl ( wndMain, "createvehicle" ) guiSetAlpha ( button11, 0.0 ) local button12 = getControl ( wndMain, "تعديلات" ) guiSetAlpha ( button12, 0.0 ) local button13 = getControl ( wndMain, "setinterior" ) guiSetAlpha ( button13, 0.0 ) local button14 = getControl ( wndMain, "ألوان" ) guiSetAlpha ( button14, 0.0 ) local button15 = getControl ( wndMain, "إصلاح" ) guiSetAlpha ( button15, 0.0 ) local button16 = getControl ( wndMain, "إنقلاب" ) guiSetAlpha ( button16, 0.0 ) local button17 = getControl ( wndMain, "الهاك" ) guiSetAlpha ( button17, 0.0 ) local setBtn = getControl ( wndSkin, "set" ) guiSetAlpha ( setBtn, 0.0 ) local c = getControl ( wndSkin, "close" ) guiSetAlpha ( c, 0.0 ) addEventHandler("onClientGUIClick", c, function () removeEventHandler("onClientRender", root, Skin) end, false) addEventHandler("onClientGUIClick", button, function () addEventHandler("onClientRender", root, Skin) end, false) As you are using GUI buttons, I used the event onClientGUIClick on the 'button' and 'c' buttons (note that I'm not using 'root' so only that buttons will call the functions so no need to do an extra if statement inside anymore). Also ! I renamed 'set' button variable as 'setBtn' because set is already a name of an existing function: set Try this and see if it works. Best regards, Citizen
  21. Citizen

    skins dd

    You need to use the shaders system which allows you to replace "on the fly" a texture by another one but it won't replace every same textures it finds, just one or more that you can specify. I never used the shaders yet and so I don't know how they work and how to use them but you will surely find examples on wiki or in the MTA Community resources. Or just wait here for someone to give you a full example Best regards, Citizen
  22. You can ! Wumbaloo you are kinda new to MTA, I don't want to be rude but if you are not sure, just don't say it. (It sounds rude I know, but i don't know how to better write it) You need to use matrix calculations. But it requires some advanced math calculations. I don't know the logics and calculations myself but I can tell you that you have to use that along with the bones positions of the player model: getPedBonePosition You can try to do it yourself (for the sake of learning) but @CrystalMV made a resource that provides you new functions that does the maths for you: Bone attachments: Website: http://crystalmv.net84.net/pages/script ... attach.php Documentation: http://crystalmv.net84.net/pages/script ... attach.php Video: MTA Community page: https://community.multitheftauto.com/index.php?p= ... ls&id=2540 You should be able to attach your parachute properly with that. Best regards, Citizen
  23. Maybe you should show us the code you did, make a screenshot of what it does and explain what is wrong and what it should be like.
  24. Hi, You can do it with a simple regex: function isValidNumber(number) return string.find(number, "^[+-]?%d+$") and true or false end Explainations: ^begining of the string [+-]?followed by an optional + or a - %d+followed by a digit (so from 0 to 9) one or multiple times $followed by the end of the string (so nothing should be after the whole number) Test it here: http://ideone.com/pyVUMb Regards, Citizen
×
×
  • Create New...