-
Posts
20 -
Joined
-
Last visited
Posts posted by TwicH
-
-
im playing on a race server with this exact problem, my custom objects work but it bugs the object for the next map, i also tried engineRestoreCOL but it does nothing and the only fix i know is to restart MTA
tldr: i think its a bug in mta
-
hi scripters of mta, I had an idea to make a platform cj would automatically "slide" on for my parkour server.
so here is what i did:
function standingcheck() local slide_platform = getElementModel (getPedContactElement ( localPlayer )) --get the model of the object cj is standing on if slide_platform == 8558 then --if its this object then local x,y,z = getElementRotation ( localPlayer ) --do some math with z variable here :D setElementVelocity ( localPlayer, 0, 0, 0) --push cj the way hes facing somehow end end addEventHandler ( "onClientPreRender", root, standingcheck )
thank you in advance.
-
Oh wait I read that wrong crap..
function follow() for i,v in pairs(zombie) do local x,y,z = getElementPosition (getLocalPlayer()) local zpx,zpy,zpz = getElementPosition (v) local zombie_angle = (360 - math.deg(math.atan2((zpx - x), (zpy - y)))) % 360 local dist = getDistanceBetweenPoints2D(x, y, zpx, zpy) if (dist > 3) then setPedCameraRotation (v,-zombie_angle) setPedControlState(v, "backwards", true) setPedControlState(v, "fire", false) elseif (dist < 3) then setPedAimTarget (v, x,y,z) setPedCameraRotation (v,-zombie_angle) setPedControlState(v, "fire", false) setPedControlState(v, "fire", true) setPedControlState(v, "fire", false) end end end
There are a few bits I'm unsure of, but this should work hopefully.
now they don't punch at all
-
Made a mistake..
function follow() for i,v in pairs(zombie) do local x,y,z = getElementPosition (getLocalPlayer()) local zpx,zpy,zpz = getElementPosition (v) local zombie_angle = (360 - math.deg(math.atan2((zpx - x), (zpy - y)))) % 360 local dist = getDistanceBetweenPoints2D(x, y, zpx, zpy) if (dist < 2) then setPedCameraRotation (v,-zombie_angle) setPedControlState(v, "backwards", true) setPedControlState(v, "fire", false) elseif (dist > 2) then setPedAimTarget (v, x,y,z) setPedCameraRotation (v,-zombie_angle) setPedControlState(v, "fire", false) setPedControlState(v, "fire", true) end end end
Had it so it would fire if the distance was bigger then two instead of smaller then.
I'm sorry to bother you but it seems like every time you fix a bug there is another one coming up, now they don't even follow me unless I get close to them. would you mind we talk on skype?
-
function follow() for i,v in pairs(zombie) do local x,y,z = getElementPosition (getLocalPlayer()) local zpx,zpy,zpz = getElementPosition (v) local zombie_angle = (360 - math.deg(math.atan2((zpx - x), (zpy - y)))) % 360 local dist = getDistanceBetweenPoints2D(x, y, zpx, zpy) if (dist > 2) then setPedCameraRotation (v,-zombie_angle) setPedControlState(v, "backwards", true) setPedControlState(v, "fire", false) elseif (dist < 2) then setPedAimTarget (v, x,y,z) setPedCameraRotation (v,-zombie_angle) setPedControlState(v, "fire", false) setPedControlState(v, "fire", true) end end end
- Changed a few things, some due to potential issues; others just to optimize the code a bit. Any ways
make sure the timer is set up right and what not.
now the zombies punch me once but wont punch again until i get far away from them
-
function follow() for i=0,maxzombies do local x,y,z = getElementPosition (localPlayer) local zpx,zpy,zpz = getElementPosition (zombie[i]) local zombie_angle = (360 - math.deg(math.atan2((zpx - x), (zpy - y)))) % 360 local dist = getDistanceBetweenPoints2D(x, y, zpx, zpy) if (dist > 2) then setPedCameraRotation (zombie[i],-zombie_angle) setPedControlState(zombie[i], "backwards", true) elseif (dist < 2) then setPedCameraRotation (zombie[i],-zombie_angle) setPedControlState(zombie[i], "fire", false) setPedControlState(zombie[i], "fire", true) end end end
I have fixed the problem but now the zombies just punch me once when they get close and never punch me again
-
local maxzombies = 30 local zombiecount = 0 zombie = {} function spawn() local x,y,z = getElementPosition (localPlayer) zombie[tostring(zombiecount)] = zombiecount local zombie[zombiecount] = createPed (20,x+math.random(-7,7),y+math.random(-7,7),z) end function follow() zpx,zpy,zpz = getElementPosition (zombie[zombiecount]) local zombie_angle = (360 - math.deg(math.atan2((zpx - x), (zpy - y)))) % 360 local dist = getDistanceBetweenPoints2D(x, y, zpx, zpy) if (dist > 2) then setPedCameraRotation (zombie[zombiecount],zombie_angle) setPedControlState(zombie[zombiecount], "forwards", true) elseif (dist < 2) then setPedControlState(zombie[zombiecount], "forwards", false) setPedControlState(zombie[zombiecount], "fire", true) end end setTimer (follow, 1000, 0) function zombie_check() if (zombiecount < maxzombies) then spawn() zombiecount = zombiecount + 1 end end setTimer (zombie_check, 100, 0) function zombie_died() zombiecount = zombiecount - 1 end addEventHandler("onClientPedWasted", getRootElement(), zombie_died)
still not working, 9: unexpected symbol near '['
-
Hello guys could somebody tell me where I went wrong with the tables?
I'm basically trying to give each zombie an id so they can follow the player
local maxzombies = 30 local zombiecount = 0 zombie{} function spawn() local x,y,z = getElementPosition (localPlayer) zombie[tostring(zombiecount)] = zombiecount local zombie[zombiecount] = createPed (20,x+math.random(-7,7),y+math.random(-7,7),z) end function follow() zpx,zpy,zpz = getElementPosition (zombie[zombiecount]) local zombie_angle = (360 - math.deg(math.atan2((zpx - x), (zpy - y)))) % 360 local dist = getDistanceBetweenPoints2D(x, y, zpx, zpy) if (dist > 2) then setPedCameraRotation (zombie[zombiecount],zombie_angle) setPedControlState(zombie[zombiecount], "forwards", true) elseif (dist < 2) then setPedControlState(zombie[zombiecount], "forwards", false) setPedControlState(zombie[zombiecount], "fire", true) end end setTimer (follow, 1000, 0) function zombie_check() if (zombiecount < maxzombies) then spawn() zombiecount = zombiecount + 1 end end setTimer (zombie_check, 100, 0) function zombie_died() zombiecount = zombiecount - 1 end addEventHandler("onClientPedWasted", getRootElement(), zombie_died)
-
Take a look at this function: https://github.com/nokizorque/GTI-sourc ... t.slua#L75
There you have all the math you have to do.
thanks
-
Hello guys, I'm just starting to learn to script and I've been stuck on this issue for a while now
local x,y,z = getElementPosition (localPlayer) local zombie = createPed (20,x+math.random(-4,4),y+math.random(-4,4),z) function follow() x,y,z = getElementPosition (localPlayer) zpx,zpy,zpz = getElementPosition (zombie) local a = zpx - x local b = y - zpy local c = a*a + b*b local sinlaw = 90/math.sin(b) local zangel = math.sin(a)*sinlaw setPedCameraRotation (zombie,zangel) setPedControlState(zombie, "forwards", true) end setTimer ( follow, 500, 0)
the code made sense the first time that I wrote it and since then I've just messed with a few variables without really thinking hoping that it would bring me an easy solution. also please don't ask me why I did the math the way I did, I'm very bad at it and that's what I came up with.
-
I tried this but player dosent work
some friend told me to use this code:
function MarkerHit ( hitPlayer, matchingDimension ) if hitPlayer == localPlayer then setPedAnimation( hitPlayer, "ped", "WOMAN_walknorm") end end addEventHandler ( "onClientMarkerHit", getRootElement(), MarkerHit )
it works but i dont know why..
-
hey guys im trying to get into scripting and i have some problem with a simple script i put together
function MarkerHit ( hitPlayer, matchingDimension ) setPedAnimation( player, "ped", "WOMAN_walknorm") end addEventHandler ( "onClientMarkerHit", getRootElement(), MarkerHit )
here is the code can you explain to me whats wrong?
-
My bad, thanks for notifying me ill will open a new one right away.
-
Hello everybody, me and my partner are looking for a scripter who is capable of making a leveling system for our server.
we are willing to pay good money for it.
contact me on skype: noamben1
-
Thanks alot, it works!
-
Hello everybody I have a simple question, how can I make a resource automatically start when the server starts?
-
Sure, everything you need is here:
yes well its too hard for me
-
up
-
Hello everybody
I need someone who knows to script to make an on foot race gamemode, something like run in FFS server.
contact me on skype: noamben1
thank you for your time
How should I do this?
in Scripting
Posted
works perfect, thank you so much