
kuwalda
Members-
Posts
92 -
Joined
-
Last visited
Everything posted by kuwalda
-
I have this part of code that I am trying to fix: function testejam() destroyElement(getElementData(thePlayer, "checkpoints")) setElementData(thePlayer, "checkpoints", createMarker(..., "checkpoint", 6, 190, 156, 252, 50, thePlayer)) setMarkerTarget(getElementData(thePlayer, "checkpoints"), ... ) setElementVisibleTo(getElementData(thePlayer, "checkpoints"), root, false) setElementVisibleTo(getElementData(thePlayer, "checkpoints"), thePlayer, true) setElementData ( thePlayer, "dbid", getElementData ( thePlayer, "dbid" ) + 1 ) end if isElementVisibleTo(getElementData(thePlayer, "checkpoints"),thePlayer) then addEventHandler( "onMarkerHit", getElementData(thePlayer, "checkpoints"), testejam ) end The thing I can`t manage to fix: if 2 players have to drive through 1 checkpoint, the first one who drives through gets "dbid" value added by +2 if 3 players have checkpoint there - first one will get "dbid" +3, second "dbid" +2 and third +1 I need that it only counts your checkpoints and only adds +1 vaule every time you hit checkpoint. Where is the problem and how can I fix it?
-
Anyone please?
-
Hello everyone, I have finally almost finished my first big script (I have posted only main part here), but I have some troubles with it, which I can`t still fix after numerous times of trying. I have commented almost every line of code, so you can understand easyer what this code does: function testejam(thePlayer, command) if ( getElementData( thePlayer, "allowrace" ) == 1 ) then --predefined value, all fine here =) local ciga = getElementData ( thePlayer, "dbid" ) --variable "ciga" contains players checkpoint ID number if ( #_G[""..getElementData( thePlayer, "raceParticipate" )..""] > ciga ) then -- checks if player have not reached last checkpoint from defined race destroyElement(getElementData(thePlayer, "checkpoints")) -- lets destroy last checkpoint setElementData(thePlayer, "checkpoints", createMarker(..., "checkpoint", 6, 190, 156, 252, 50, thePlayer)) -- store that all big checkpoint info in players element data setMarkerTarget(getElementData(thePlayer, "checkpoints"),... ) -- and its sets its target point setElementVisibleTo(getElementData(thePlayer, "checkpoints"), root, false) -- noone sees checkpoint setElementVisibleTo(getElementData(thePlayer, "checkpoints"), thePlayer, true) -- ^ exept player setElementData ( thePlayer, "dbid", getElementData ( thePlayer, "dbid" ) + 1 ) -- and adds up +1 to next checkpoint for next time on activating end if isElementVisibleTo(getElementData(thePlayer, "checkpoints"),thePlayer) then -- if player can see this checkpoint addEventHandler( "onMarkerHit", getElementData(thePlayer, "checkpoints"), testejam ) -- you can activate same loop on next time hiting that checkpoint end end end --Command to type, to active this event only once addCommandHandler("race", function (thePlayer, command) if (getElementData(thePlayer, "allowedToUseThisCommand") == true) then testejam(thePlayer, command) setElementData( thePlayer, "allowedToUseThisCommand", false) end end ) (you may want to copy this into some text editor to see those lines better) With this script I have 2 main problems: * When any player types /race , this race is activated for everyone. Other players can`t see 1st checkpoint, but when they drive through them, they activate the whole loop and are into race. * When 2 players have checkpoint at same place ("dbid" value is the same for both players), then: first player who reaches this checkpoint drives as normal, everything is fine for him second player who reaches this checkpoint, after reaching it, gets +2 to his "dbid" value, meaning he skips 1 checkpoint. Like if I see checkpoint number 5, after hitting it I will see checkpoint number 7 instantly. If anyone have found my mistakes or can suggest anything, I would be greatful, because I have tried to fix these problems over an week.
-
Thanks, that`s what I was looking for!
-
I have made command: addCommandHandler("race", testejam) Problem is, it`s activating function, which should be activated only once with this command. Like I type /race and then, I can`t type /race anymore. How can I do it? I thought something like this would work, but I got a bit confused: addCommandHandler("race", function (thePlayer, command) if (getElementData(thePlayer, "allowedToUseThisCommand") == 1) then testejam --what next? how to call this "testejam" function? end end )
-
Could you please tell me why these things don`t work for me: setElementData( localPlayer, "meetingpoint", createMarker( _G[""..getElementData( localPlayer, "raceParticipate" )..""][1][1], _G[""..getElementData( localPlayer, "raceParticipate" )..""][1][2], _G[""..getElementData( localPlayer, "raceParticipate" )..""][1][3], "checkpoint", 6, 116, 237, 5, 90 )) setMarkerIcon(getElementData(localplayer, "meetingpoint"), "finish" ) Marker is being created, but "finish" icon is not set deletothis = getElementData(thePlayer, "meetingpoint") destroyElement(deletothis) And later on, why does this is not deleting that marker? As I would have to guess, there is some kinda problem with getElementData
-
setElementData( localPlayer, "raceParticipate", raceActive["participate"] ) if ( getElementData( localPlayer, "raceParticipate" ) == "blueBerryRally" ) then _G[""..getElementData( localPlayer, "raceParticipate" )..""] = blueBerryRally elseif ( getElementData( localPlayer, "raceParticipate" ) == "blueBerryRallyReversed" ) then _G[""..getElementData( localPlayer, "raceParticipate" )..""] = blueBerryRallyReversed elseif ( getElementData( localPlayer, "raceParticipate" ) == "tourTheSanAndreas" ) then _G[""..getElementData( localPlayer, "raceParticipate" )..""] = tourTheSanAndreas end meetingPoint = createMarker ( _G[""..getElementData( localPlayer, "raceParticipate" )..""][1][1], _G[""..getElementData( localPlayer, "raceParticipate" )..""][1][2], _G[""..getElementData( localPlayer, "raceParticipate" )..""][1][3], "checkpoint", 6, 116, 237, 5, 90 ) createBlip( _G[""..getElementData( localPlayer, "raceParticipate" )..""][1][1], _G[""..getElementData( localPlayer, "raceParticipate" )..""][1][2], _G[""..getElementData( localPlayer, "raceParticipate" )..""][1][3], 53, 2, 0, 0, 255, 0, 1000 ) Basicly this code sets ElementData to player, with race he wanted participate. And later on with if and elseif statements I convert that string value to variable and use it to createMarker and createBlip. In that code, it creates marker and blip using table pre-stored coordinates. So what I wanted to ask - how can I make this part simplier, so I dont have to make this elseif statement for every race map name? : if ( getElementData( localPlayer, "raceParticipate" ) == "blueBerryRally" ) then _G[""..getElementData( localPlayer, "raceParticipate" )..""] = blueBerryRally elseif ( getElementData( localPlayer, "raceParticipate" ) == "blueBerryRallyReversed" ) then _G[""..getElementData( localPlayer, "raceParticipate" )..""] = blueBerryRallyReversed elseif ( getElementData( localPlayer, "raceParticipate" ) == "tourTheSanAndreas" ) then _G[""..getElementData( localPlayer, "raceParticipate" )..""] = tourTheSanAndreas end
-
loadstring(raceActive["participate"]) does not work with if ( #loadstring(raceActive["participate"]) - 1 == value ) then Anyone can think out some alternative for using it here?
-
Huge thanks to you, it was that I was searching for!
-
any alternitives to this?
-
I have simple question - if I have string value, can I use it as variable? example = { } example[settings][1] = "thePlayer" example[settings][2] = "root" example[settings][3] = "functionX" if isElementVisibleTo ( marker, example[settings][1] ) then
-
No, you dont understand me and I know what I want! I have race checkpoints, which are stored in tables: blueBerryRally = { } blueBerryRally[1] = { 679.20001, 312.39999, 18.9 } blueBerryRally[2] = { 588.70001, 294.60001, 17.7 } blueBerryRally[3] = { 530.29999, 249.8, 13.9 } ... blueBerryRallyReversed = { } blueBerryRallyReversed[1] = { 675.70001, 312.79999, 18.9 } blueBerryRallyReversed[2] = { 785.59998, 330.10001, 18.9 } blueBerryRallyReversed[3] = { 892.70001, 359.5, 18.9 } ... Now when I random: raceAvailableForUse = { } raceAvailableForUse[1] = "blueBerryRally" raceAvailableForUse[2] = "blueBerryRallyReversed" raceMap = raceAvailableForUse[math.random(#raceAvailableForUse)] raceActive["participate"] = raceMap it will return either blueBerryRally or blueBerryRallyReversed ,but this element is string. So when I use: local raceNameForMarker = raceActive["participate"] meetingPoint = createMarker ( raceNameForMarker[1], raceNameForMarker[2], raceNameForMarker[3], "checkpoint", 6, 116, 237, 5, 255 ) it can`t make meetingpoint, because raceActive["participate"] vaule is string. I am asking, how can I make this raceActive["participate"] a variable, so when I use it in my createMarker function, it works?
-
I don`t really undrestud what you said...
-
Hello. Story about my problem is really short and clean, so I will try to keep it like that: function triggers and random race is selected raceMap = raceAvailableForUse[math.random(#raceAvailableForUse)] this variable is used to triggerClientEvent and is passed to next function And this variable is inserted into table, so we know map name that was randomed = raceActive["participate"] = raceMap But problem starts here - how can I use this table element to make name for table to use: raceNameForMarker = raceActive["participate"] meetingPoint = createMarker ( raceNameForMarker[1], raceNameForMarker[2], raceNameForMarker[3], "checkpoint", 6, 116, 237, 5, 255 ) I hope you undestanded what I wanted to ask. If anyone have any other solutions, I would like to hear them.
-
Thanks for you time and effort helping me, but to be more clearer about my problem: when player is driving this race and other player types /race afterwards, first players checkpoints are being "stolen" and does not appear anymore, also second player are able to use those checkpoints, which were defined for first player.
-
Okey, here is my code for simple racing system, but why do other players are allowed to use other players checkpoints. playerMarkerTable = { } function testejam(thePlayer, command) if ( getElementData( thePlayer, "allowrace" ) == 1 ) then if ( getElementData ( thePlayer, "dbid" ) == 2 ) then setElementData(thePlayer, "laiks", getTickCount ()) end local ciga = getElementData ( thePlayer, "dbid" ) outputChatBox("Tavs ID:"..tonumber(ciga)..".", thePlayer, 255, 255, 0) destroyElement(playerMarkerTable[thePlayer]) playerMarkerTable[thePlayer] = createMarker(blueBerryRally[ciga][1], blueBerryRally[ciga][2], blueBerryRally[ciga][3], "checkpoint", 6, 190, 156, 252, 170) setElementVisibleTo(playerMarkerTable[thePlayer], root, false) setElementVisibleTo(playerMarkerTable[thePlayer], thePlayer, true) if ( #blueBerryRally == ciga ) then outputChatBox("Finish:"..(getTickCount () - getElementData( thePlayer, "laiks" )) / 1000 .."sec. GL NEXT TIME", root, 255, 255, 0) setElementData(thePlayer, "dbid", 1) destroyElement(playerMarkerTable[thePlayer]) end setElementData ( thePlayer, "dbid", getElementData ( thePlayer, "dbid" ) + 1 ) if isElementVisibleTo(playerMarkerTable[thePlayer],thePlayer) then addEventHandler( "onMarkerHit", playerMarkerTable[thePlayer], testejam ) end end end addCommandHandler("race", testejam) I belive problem is in if isElementVisibleTo(playerMarkerTable[thePlayer],thePlayer) then ,but how is it possible for that player to see that element? Please help, I have no idea what is wrong here.
-
I tried, but it didn`t worked - same error
-
I got this function going on for me function testejam(thePlayer, command) if ( getElementData( thePlayer, "allowrace" ) == 1 ) then if ( getElementData ( thePlayer, "dbid" ) == 2 ) then setElementData(thePlayer, "laiks", getTickCount ()) end local ciga = getElementData ( thePlayer, "dbid" ) outputChatBox("Tavs ID:"..tonumber(ciga)..".", thePlayer, 255, 255, 0) destroyElement(markeritis) markeritis = createMarker ( blueBerryRally[ciga][1], blueBerryRally[ciga][2], blueBerryRally[ciga][3], "checkpoint", 6, 190, 156, 252, 170 ) setElementVisibleTo(markeritis, root, false) setElementVisibleTo(markeritis, thePlayer, true) if ( #blueBerryRally == ciga ) then outputChatBox(Finished", thePlayer, 255, 255, 0) outputChatBox("Finisha time:"..(getTickCount () - getElementData( thePlayer, "laiks" )) / 1000 .."sec. GL NEXT TIME", root, 255, 255, 0) setElementData(thePlayer, "dbid", 1) end setElementData ( thePlayer, "dbid", getElementData ( thePlayer, "dbid" ) + 1 ) if isElementVisibleTo(markeritis,source) then addEventHandler( "onMarkerHit", markeritis, testejam ) end end end addCommandHandler("race", testejam) And my question is - why does it give Bad argument @ 'isElementVisibleTo' [Expected element at argument 2, got nil] ? Have tried alot of variables, none of them worked.
-
Hello. I have a bit problem with my script: function testejam(thePlayer, command) if ( getElementData ( thePlayer, "dbid" ) == 2 ) then setElementData(thePlayer, "time", getTickCount ()) end local pid = getElementData ( thePlayer, "dbid" ) local ciga = getElementData ( thePlayer, "dbid" ) destroyElement(markeritis) markeritis = createMarker ( blueBerryRally[ciga][1], blueBerryRally[ciga][2], blueBerryRally[ciga][3], "checkpoint", 6, 190, 156, 252, 170 ) if ( #blueBerryRally == ciga ) then outputChatBox("You finished, nice", thePlayer, 255, 255, 0) outputChatBox("Your time:"..(getTickCount () - getElementData( thePlayer, "time" )) / 1000 .."sec.", root, 255, 255, 0) setElementData(thePlayer, "dbid", 1) end setElementData ( thePlayer, "dbid", getElementData ( thePlayer, "dbid" ) + 1 ) addEventHandler( "onMarkerHit", markeritis, testejam ) end addCommandHandler("race", testejam) But I still have some problems I haven`t figured out how to fix them: * when player types /race ,why does everyone sees checkpoints and are allowed to drive through them? I have tried using setElementVisibleTo function but it works only partly.? How to make those checkpoints availabe only for that person, who asked for /race ? * when player finishes race, his time is stored in table, for later use. Lets say i have 3 guys who have raced: x with time 21sec y with time 15sec z with time 17sec How to determen witch one of those was fastest? How to write it in code? * Is it possible to make this script work for multiple people? For that I mean if someone is driving this track and someone else types /race, he gets his own checkpoints and wont disturb other players? And one more question offtopic - how can I make variable, with variable. Like: x = 6 theplayernamex ,so it would be like theplayername6
-
Hey, I have some questions that I could not find answers to, so I thought you could help: addEventHandler('onClientGUIClick', getRootElement(), function(button, state, absoluteX, absoluteY) if(source == button1)then ... end end end) How can I define who pressed the button? Like getting "theplayer" variable. if getElementData(thePlayer, "dbid") == nil then setElementData(thePlayer, "dbid", 1) end Why this is not working? I did not define "dbid" anywhere before, but isn`t returned value not existant / nil ? function testejam(thePlayer, command) local pid = tonumber(getElementData(thePlayer, "dbid")) outputChatBox("Your ID:"..pid..".", thePlayer, 255, 255, 0) local ciga = getElementData ( thePlayer, "dbid" ) destroyElement(markeritis) markeritis = createMarker ( blueBerryRally[ciga][1], blueBerryRally[ciga][2], blueBerryRally[ciga][3], "checkpoint", 6, 190, 156, 252, 170 ) setElementData ( thePlayer, "dbid", getElementData ( thePlayer, "dbid" ) + 1 ) addEventHandler( "onMarkerHit", markeritis, testejam ) end addCommandHandler("race", testejam) Why does it give error: attempt to concatenate local 'pid' (a nil value) ? How can I determen if there is no more checkpoints left? Should I use if (markeritis == false) then ? Thanks for your replys, time and help!
-
Anyone please? How to make "checkpoint chain" where first checkpoint leads to second, when checkpoints are stored in table and also make them appear for each player induvidualy , so there is no thing like playerX hits checkpoint1 and playerY sees checkpoint2. I have been trying to figure it out myself, but nothing is leading me anywhere. I googled it and there is no article about it. blueBerryRallyz = createMarker ( 679.20001, 312.39999, 18.9, "checkpoint", 6, 190, 156, 252, 170 ) addEventHandler( "onClientElementColShapeHit", getRootElement( ), function ( ) destroyElement(blueBerryRallyz) end ); Does not work out for me blueBerryRallyz = createMarker ( 679.20001, 312.39999, 18.9, "checkpoint", 6, 190, 156, 252, 170 ) function ColShapeHit ( thePlayer ) local detection = isElementWithinColShape ( thePlayer, blueBerryRallyz ) if detection then destroyElement( blueBerryRallyz ) createMarker ( 574,59998, 286.39999, 16.9, "checkpoint", 6, 190, 156, 252, 170 ) end end addEventHandler( "onClientElementColShapeHit", getRootElement( ), ColShapeHit ) And this neather. So what is correct way doing this?
-
Hello. I wanted to ask some questions. I have made table with all my race checkpoints and want to make "chain effect", with that I mean, you enter checkpoint1 and then checkpoint2 appears and so on. But how can I do it, because onMarkerHit is server sided event, but I want every player to "go trough this chain" not like 1 player drives through checkpoint 1 and server shows checkpoint 2 for everyone. Also, how can I make this "chain effect"? Will simple "checkpoint["1" +1 ]" work? And also, how do I determen which player won the race? Like when they hit last checkpoint, how can I make something like - ("onMarkerHit", checkpoint[LAST ELEMENT], dothat)?
-
Hey, I was wondering if it`s possible to add race events into "default" gamemode? With that I mean I have collected checkpoints and want to insert race events into main gamemode. For example, server tells ""Type /gorace to join race" and after player types in that command, he is added to some kind of list. Afterwards there is made checkpoint, so they know where to drive for race start. But what next? How to make players drive trough checkpoints and make them invduvidual for everyone? There is definetly tables and client sided scripts, but I have my main question - how to make, drive trough "checkpoint1" and then appears "checkpoint2"? Thanks for any advices!
-
No, there is button in GUI to close the last one. If I wouldnt close it on first time, there would be in total of 3 GUIs when event is triggered 2nd time
-
I know, but that is not my problem. The problem is like this: * I join the server * My friend join the server * event is triggered * GUI pops out for both of us * My friend leaves the server * I reset value to raceActive[1] = "false" * My friend join the server * event is triggered * GUI pops out for both of us and ANOTHER GUI pops out on top of last one So basiclly event is being triggered 2 times, but I have no idea what causes it.