
[FOTL]Aphex
Members-
Posts
35 -
Joined
-
Last visited
-
Days Won
1
[FOTL]Aphex last won the day on July 8 2024
[FOTL]Aphex had the most liked content!
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
[FOTL]Aphex's Achievements

Rat (9/54)
1
Reputation
-
So I'm trying to make a simple platformer race thing with platform game controls (A and D = left and right, W = jump) To do this I first toggleAllControls to false and then use bindKey to do what I want with my keys (control acceleration and set the vehicle Z rotation to 90 or -90) The problem I'm finding is it only works sometimes. The intended functionality is that when you press D the car moves in a straight line along the X axis, when you press A the car moves in a straight line on the same axis but in the opposite direction. What sometimes happens is the toggleAllControls doesn't seem to be working properly so the car will also slide along the Y axis. As you can see I've tried fiddling with the order of the functions (using timers to try an better understand what could be happening)... but to no avail. -- client function startup() setTimer( function() toggleAllControls (false, true, false) toggleControl ( "vehicle_left", false ) toggleControl ( "vehicle_right", false ) end, 1000, 1) setTimer( function() keys() invincible() outputChatBox("GO!") end, 2000, 1) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), startup) function invincible() local veh = getPedOccupiedVehicle(localPlayer) setVehicleDamageProof(veh, true) end function leftRight ( key, keyState ) local veh = getPedOccupiedVehicle(localPlayer) local rx, ry, rz = getElementRotation(veh) if key == "d" then if keyState == "down" then setControlState ( localPlayer, "accelerate", true ) setElementRotation(veh, rx, ry, 90) elseif keyState == "up" then setControlState ( localPlayer, "accelerate", false ) end elseif key == "a" then if keyState == "down" then setControlState ( localPlayer, "accelerate", true ) setElementRotation(veh, rx, ry, -90) elseif keyState == "up" then setControlState ( localPlayer, "accelerate", false ) end end end function keys ( commandName ) bindKey( "d", "down", leftRight ) bindKey( "d", "up", leftRight ) bindKey( "a", "down", leftRight ) bindKey( "a", "up", leftRight ) bindKey( "w", "down", jumpy ) end function onClientRender() local x, y, z = getElementPosition(localPlayer) setCameraMatrix(x, y+10, z, x, y, z, 0, 100) end addEventHandler("onClientRender", root, onClientRender) function jumpy() local veh = getPedOccupiedVehicle(getLocalPlayer()) if (veh) then if isVehicleOnGround(veh) == true then doubleJump = true local sx,sy,sz = getElementVelocity(veh) setElementVelocity (veh, sx, sy, 0.3) elseif isVehicleOnGround(veh) == false and doubleJump then doubleJump = false local sx,sy,sz = getElementVelocity(veh) setElementVelocity (veh, sx, sy, 0.3) end end end Any ideas what I'm doing wrong?
-
I get a bunch of debug warnings and errors in my race map...
[FOTL]Aphex posted a topic in Scripting
I get a bunch of warnings when I load the map in the editor (before I even test it) [14:11:13] WARNING: edf\edf.lua:1374: Attribute 'nextid' has an invalid type in element 'checkpoint': should be 'element'. [14:11:13] WARNING: edf\edf.lua:830: Bad argument @ 'getElementType' [Expected element at argument 1, got string 'false'] [14:11:13] WARNING: edf\edf.lua:776: Bad argument @ 'getElementData' [Expected element at argument 1, got string 'false'] [14:11:13] WARNING: edf\edf.lua:837: Bad argument @ 'getElementData' [Expected element at argument 1, got string 'false'] [14:11:13] WARNING: edf\edf.lua:838: Bad argument @ 'getElementData' [Expected element at argument 1, got string 'false'] [14:11:13] WARNING: edf\edf.lua:839: Bad argument @ 'getElementData' [Expected element at argument 1, got string 'false'] user_name opened map [R]-Darts. (opening took 75 ms) Then, when I test the map, AFTER I hit the last checkpoint I get this: Notice: Collisions are turned off for this map Notice: Vehicle weapons are turned off for this map Notice: Collisions are turned off for this map Notice: Vehicle weapons are turned off for this map Notice: Collisions are turned off for this map Notice: Vehicle weapons are turned off for this map Notice: Collisions are turned off for this map Notice: Vehicle weapons are turned off for this map Notice: Collisions are turned off for this map Notice: Vehicle weapons are turned off for this map Notice: Collisions are turned off for this map Notice: Vehicle weapons are turned off for this map etc... and then these errors when the editor loads back in: ERROR: killmessages'scripts'client\c.ui.lua:69 attempt to index local 'victim' (a nil value) INFO: Resource stopping ERROR: killmessages'scripts'client\c.ui.lua:69 attempt to index local 'victim' (a nil value) [DUP x385] ERROR: Server triggered clientside event onClientCall_race, but event is not added clientside Also, sometimes (not always) when I select to test the race I get this warning and the map doesn't load, editor just kinda hangs there and I have to press F5 again to actually load the map WARNING: editor_main\serverloadtest_server.lua834: Bad argument @ 'addEventHandler' [Expected element at argument 2, got boolean] I've tried reinstalling MTA but it hasn't fixed it. Any ideas? -
Thanks again, your knowledge and insight are very much appreciated. I bit the bullet and installed a VM to test my map with more than one player and, miracle of miracles, it worked! I'll definitely use your examples in future though... serverside stuff still scares me a bit lol
-
Thanks a lot for the reply. So I'm familiar with tables but I'm not sure I understand how such a table would be for keeping track of individual checkpoint progress, would it be something like this? With a `for` loop checking/dictating which markers are visible to which players? c = { {player_1, checkpoint_reached}, {player_2, checkpoint_reached}, {player_3, checkpoint_reached}, ... } Before I tried it with `set` and `getElementData` but i must have done something wrong because it didn't work as intended... So yeah, I think I'll leave serverside until I'm a bit more confident with my scripting abilities lol. But for now you think my clientside script with ... if(hitElement == localPlayer) then ...SHOULD work? Maybe?? (I haven't had the opportunity to test it with someone else since I changed to that)
-
[FOTL]Aphex started following Dynamic race markers/checkpoints
-
So I'm trying to make a race with dynamic checkpoints (using markers). The basic logic is as such: First two checkpoints are created at the start When you hit Checkpoint_1... Checkpoint_1 is destroyed Checkpoint_3 is created Keep going until the last checkpoint. So basically just like the Race Resource checkpoints, except respawning isn't a concern because it's a deathmatch anyway so if you're dead you're out. It works fine in the editor (in single player) but the issue I have is that when I test it with another player when either one of you hits a marker it is destroyed for both players. Client function markerHandler(hitElement) if(hitElement == localPlayer) then if(source == cp1) then --create/destroy markers and blips, etc end if(source == cp2) then --create/destroy markers and blips, etc end if(source == cp3) then --create/destroy markers and blips, etc endGame() end end end addEventHandler("onClientMarkerHit", getRootElement(), markerHandler) So is there any way to only see and affect the markers created on your own client? Or is this way more complicated than my nooby scripting skills will allow? (I did initially try to do it serverside but it fried my brain so I figured clientside would be simpler)
-
I'm having the same problems as everybody else, are there any plans to fix it?
-
Thanks I also had to delete the "local" from local iconimg = guiClientStaticImage...
-
So I want to change a gui image when you hit a marker, so far I have this... server function omg_ramptest() CP1 = createMarker (2445, -1660, 13, "cylinder", 4, 255, 0, 0, 255) omgMover1(1) end function randomCar(player, dimension) if source == CP1 then if getElementType(player) == "player" then local veh = getPedOccupiedVehicle(player) if veh then triggerClientEvent ( "triggered", getRootElement(), 1 ) end end end end addEventHandler('onMarkerHit', getRootElement(), randomCar) client function makeicon() local x,y = guiGetScreenSize() local iconimg = guiCreateStaticImage( (x/2)-25, y/15, 50, 50, "icon5.png", false ) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), makeicon) function changeicon() guiStaticImageLoadImage ( iconimg, icon2.png ) end function trigger ( message ) outputChatBox ( "The server says: " .. message ) changeicon end addEvent( "triggered", true ) addEventHandler( "triggered", getRootElement(), trigger ) The initial image (icon5.png) displays and when you hit the marker I get the "The server says:" message, but ONLY when I delete the trigger function and contain it in it's own lua file. I can't get it to trigger the guiStaticImageLoadImage function. Any ideas?
-
Any way to check if wheels are on the floor?
[FOTL]Aphex replied to [FOTL]Aphex's topic in Scripting
haha yeah thats what I meant... I've just been scouring the wiki and didn't spot it. Thanks a lot... and for the quick reply! -
I'm making a jump script that works fine so far, but I'd like it to be so that when you jump you cant jump until you're on the floor again. As it is at the moment I just have a timer that only lets you jump once every 500ms, but if they were to jump off somewhere high they could still "jump" every 500ms. I've tried checking the Z velocity first, to make sure it was between -0.02 and 0.02, but the jump doesnt work if you're driving up or downhill... or at the peak of the jump (you're z velocity goes to 0 momentarily). function jumpy(player) local veh = getPedOccupiedVehicle(player) if ok == true then if (veh) then local x,y,z = getElementVelocity(veh) setElementVelocity (veh, x, y, z+0.2) ok = false setTimer(function() ok = true end,500,1) end end end
-
It works! Thanks immensely!
-
Hey, thanks a lot Can't test it til tomorrow, but yea... thanks muchly!
-
Hi, how can I make a script that will allow players to change vehicles by pressing a key? I have a script that will change you to a random vehicle when you hit a checkpoint, but I dont know how to convert it to work with key presses instead! function randomCar(checkpoint, time) local veh = getPedOccupiedVehicle(source) if 1 <= checkpoint and checkpoint <= 8 then local x,y,z = getElementPosition(veh) setElementModel (veh, carids[math.random(#carids)]) setElementPosition (veh, x, y, z+2) end end addEvent('onPlayerReachCheckpoint') addEventHandler('onPlayerReachCheckpoint', getRootElement(), randomCar) I've been looking at this example from the wiki for keypresses function playerPressedKey(button, press) if (press) then -- Only output when they press it down outputChatBox("You pressed the "..button.." key!") end end addEventHandler("onClientKey", root, playerPressedKey)
-
*facepalm* If you actually READ my original post you'll notice that I said that I've found a workaround so that everything works as normal. Why would I then want to run a diagnostic tool that would likely tell me less than I already know, to help me to fix a problem I have already fixed? I only posted this originally so that the devs would be made aware of a bug that has affected me and at least one other person. I was "doing my bit for the community". But then what. I get set upon by the forum idiot and then some overzealous mod decides to move the thread to the mapping support section even though the main symptom is one where the MTA client crashes. Round of applause to all involved, well done guys (Just in case you didn't realise, that was sarcasm).
-
FUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUCK You really ARE retaded!!!!! How many times do I have to point out to you that i didn't delete ANYTHING from the server folders! Now read that again! i didn't delete ANYTHING from the server folders! and anyway, even If i had (which I haven't) how would the editor then work without any problems?! You're f ucking double retarded! Jesus F ucking christ!