Jump to content

kuwalda

Members
  • Posts

    92
  • Joined

  • Last visited

Everything posted by kuwalda

  1. Yes, because this GUI tells information about race event and it gets random values everytime, so information in this GUI is changing. raceRikotajs = Rikotajs[ math.random( 1,#Rikotajs ) ]
  2. I want it to show to everyone, but I dont want it to trigger 2 times and show 2 GUIs at once. As I said, GUI shows only once for each player when I trigger it first time, but when I trigger it second time, it shows 2 GUIs per player. --[CLIENT] And displays GUI function showRaceGUI ( raceRikotajs ) ... end addEvent( "gotRaceGUI", true ) addEventHandler( "gotRaceGUI", getRootElement(), showRaceGUI ) With GUI everything should be fine, there is just styling options. As I understand problem is somewhere in first or second "step"
  3. There is Client and Server sides, I have marked them with --[sERVER] or --[CLIENT]
  4. I have been creating automatic race system and for now all was fine, until I found a little bug that I am unable to find and fix. Script idea: --[sERVER] Script considers to make race or not function raceConsider( ) if getPlayerCount() >= 2 then if raceActive[1] == "false" then triggerClientEvent ( "showRaceInfo", getRootElement()) raceActive[1] = "true" end end end addEventHandler ( "onPlayerJoin", getRootElement(), raceConsider ) --[CLIENT] Sets timer to allow player login, so he can freely look at GUI function showRaceInformation ( ) setTimer ( function ()triggerServerEvent( "needRaceGUI", root)end, 15000, 1) end addEvent( "showRaceInfo", true ) addEventHandler( "showRaceInfo", getRootElement(), showRaceInformation ) --[sERVER] Gathers information for race function getRaceGUI( ) raceRikotajs = Rikotajs[ math.random( 1,#Rikotajs ) ] triggerClientEvent(root, "gotRaceGUI", root, raceRikotajs) end addEvent( "needRaceGUI", true ) addEventHandler( "needRaceGUI", root, getRaceGUI ) --[CLIENT] And displays GUI function showRaceGUI ( raceRikotajs ) ... end addEvent( "gotRaceGUI", true ) addEventHandler( "gotRaceGUI", getRootElement(), showRaceGUI ) Problem is: when I am connected to server and my friend joins it - all works perfectly and fine, but when I reset raceActive[1] = "true" to raceActive[1] = "false" and my friend joins this GUI is displaying 2 times. How to make it apper only 1 time? Where did I go wrong?
  5. speakeruArray = { } function speakerCP(thePlayer, command, whatIwant, setting, number, vehicle) if tostring(whatIwant) == "place" then local x, y, z = getElementPosition(thePlayer) outputChatBox(number, thePlayer, 0, 250, 0) speakeruArray[number] = createObject(2229, x, y, z-1) outputChatBox("created a speaker!", thePlayer, 0, 250, 0) elseif tostring(whatIwant) == "remove" then destroyElement(speakeruArray.cipars) table.remove (speakeruArray, cipars) outputChatBox("destroyed the Speaker!", thePlayer, 0, 0, 255) elseif tostring(lemums) == "debug" then for i, v in pairs( speakeruArray ) do outputChatBox("DEBUG:"..i..".", root, 255, 255, 0) end end Debug is working as it should - displaying 1,2,3,4... But removeing is not, as it only displays "You have Succesfully destroyed the Speaker!" ,but rest is giving error Bad argument @ 'destroyElement' [Expected element at argument 1, got nil] EDIT: HUGE THANKS TO EVERYONE who helped me, omg ... finally it is working as it should. Thank you all.
  6. Thanks for replys, they really helped alot, but still there is one more small problem with deleting those objects: --Creation speakeruArray[number] = createObject(2229, x, y, z-1) --Removing destroyElement(speakeruArray.number) table.remove (speakeruArray, number) -- wihch is giving out -- Bad argument @ 'destroyElement' [Expected element at argument 1, got nil] So when I made small command for i, v in pairs( speakeruArray ) do outputChatBox("DEBUG:"..i..".", root, 255, 255, 0) end I realised all "i" values were my defined numbers, so is that fine or that is my problem?
  7. Hi. I made topic before about my problem about speaker objects, but it helped me only partly. Main problems that accoured me: --Creating array speakeruArray { } --creating entry in array with key foo and value.. speakeruArray["foo"] = createObject(2229, x, y, z-1) --trying to delete this object using does not work destroyElement(speakeruArray["foo"]) table.remove ( speakeruArray["foo"]) And my second question is about right syntax for using variable as key for table. For example speakeruArray[myDefinedNumber] = createObject(2229, x, y, z-1) Sorry for being such pain in ass for someone, but I have tried to figure this all out for myself for hours and nothing have worked.
  8. Thanks for replays, I managed to work something out, but I think it was total shot in the dark for me. For speaker create I use table.insert ( speakerArray, createObject(2229, x, y, z-1) ) Which works fine, but I can`t manage to remove them by using destroyElement(speakerArray[1]) table.remove ( speakerArray, 1 ) And table was created using speakerArray = { }
  9. Hello. My problem is that when I create "speaker object" with "speakerObject = createObject(2229, x, y, z-1)" it stores object data to this global variable. Everything is fine, but when I want to add more of these "speaker objects" they ofcorse overwrite "speakerObject" variable. So my question is - how do I make some kind of list for all of those speakers and numerate them in some kind of order for later use? Like /speaker [id] [settings...] One of my solutions was array, but I was not quite sure how to use them, because I have other settings for these speakers, like sound volume, radio station and so on. Any help will be appriciated.
  10. Nice, thank you - it worked. Still one more small question - why my setCameraMatrix isn`t working? addEventHandler( "onClientResourceStart", getRootElement( ), function ( ) setCameraMatrix(localPlayer, 1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316) guiSetVisible( login_register_window, true ) showCursor(true) guiSetInputEnabled(true) fadeCamera(source, true, 5) end ); I tried changing localPlayer to many other variables, but still no change, just black screen.
  11. Hello everyone, I have a bit complicated situation over here. Basiclly I have MYSQL account system witch works fine, it asks for users username and password when it`s activated by "onPlayerJoin" event. Everything is good until server dosen`t ask client to download anything, with that I mean: * player joins server * player download resources * nothing comes forward, login request isn`t incomming And then if you recconect to server everything is working smooth, but it messes up my Account system. I`ve been trying using "onClientResourceStart" ,but either I messed up with it or it isn`t right solution for me. So in conclusion what I wanted to ask - how do you trigger login request event after all files have been downloaded. Or maybe someone else have better solution. If someone wants, here is brief code explanation: --server event (this works 100% of times) addEventHandler("onPlayerJoin", getRootElement(), function() triggerClientEvent(source, "onJoin", getRootElement()) outputChatBox("Event triggered", player, 255, 255, 255) end ) --and after comes client side event, whitch is working after 2nd time of joining function playerJoin() setCameraMatrix(...) guiSetVisible( login_register_window, true ) showCursor(true) guiSetInputEnabled(true) fadeCamera(source, true, 5) outputChatBox("Event triggered", player, 255, 255, 255) end addEvent("onJoin", true) addEventHandler("onJoin", getRootElement(), playerJoin)
  12. Hey, I have been trying to figure out why my close button isn`t working and still have not found anything. Maybe someone can spot where is my mistake? function showRaceGUI ( message ) local screenW, screenH = guiGetScreenSize() raceInformation = guiCreateWindow((screenW - 447) / 2, (screenH - 412) / 2, 447, 412, "Race name", false) GUIaizvert = guiCreateButton(23, 334, 400, 64, "Close", false, raceInformation) showCursor(true) end --Closing button function close() if source == GUIaizvert then guiSetVisible(raceInformation,false) showCursor(false) end end addEventHandler("onClientGUIClick", GUIaizvert, close)
  13. Hello! I have this strange problem that I am very confused about. Story is simple - when I add "" or any other entry in acl.xml file it just disappears later on. I noticed when I turn off my server using that red X button on top right everything is fine, but as soon as I use shutdown command it just disappears. Also when I try to access my webadmin panel it asks for my username and password. I 100% enter them right, even consule says that, but it still keeps asking me for my username and password continously. I think that could be related to problem mentioned above. Any advice would be helpful, because I just started to make server from zero point and I have no idea what cause this. EDIT: Okey, I just deleted all ACL permissions under Admin group and my added lines are not deleted now, but still I cant access webadmin
  14. https://community.multitheftauto.com/in ... ls&id=5524 This might be what you are looking for
  15. I use bindKey( "num_add", "both", setPlayerGear ) EDIT: Okey thanks, I got it working with: if key == "num_add" and ( getKeyState( "lctrl" ) == true ) then But how do I force player to release the button, so its not like just driving and holding LCTRL all the time to switch gears? Something like freeze vechile movement speed or... any ideas?
  16. Hello. I was just messing around with trying to make vehicle clutch system when changing gears. The code looks something like: function setPlayerGear( key, keyState ) if ( key == "num_add" and keyState == "up" ) then if playerGear < 5 then playerGear = playerGear + 1 local sound = playSound("grind.wav") setSoundVolume(sound, 0.3) end elseif ( key == "num_sub" and keyState == "up" ) then if playerGear > -1 then playerGear = playerGear - 1 local sound = playSound("grind.wav") setSoundVolume(sound, 0.3) end end end And it works fine when changing gears, but when I tried to add Cluch system, where player must press LCTRL and then they are allowed to change gear, i failed. I tried something like: if ( key == "num_add" and keyState == "up" ) and ( key == "lctrl" and keyState == "down" ) then But it didn`t work. Maybe someone see where is the problem and can help me out.
×
×
  • Create New...