i ran over the strip about 15 times at varying speeds and it didnt delete once
Hmm, I wasnāt a fan of vRP when I used it so Iām not able to test if it works on that framework. You should disable any other resources, clear server cache, maybe even clear your client cache in the fivem/dunno folder. Triple check that you didnāt copy the Citizen.Wait ( 200 ) code from the post I mentioned earlier. Make sure the code you pasted into your client.lua exactly matches up with the code you see in the first post, including formatting.
Anyone know how to make it so it spawns infront of the player?
I feel the pain, but it seems like the people with a little less knowledge get to understand. I mean I am learning the coding, but still trying to process this stuffā¦ I praise the people who make the files downloadable, makes life just a little easier.
I created a resource file for both the EssentialMode and FXServer version.
I figured a quick download will allow people to test and learn faster. Let me know if you donāt want this up.
Simply edit this line in the client script:
local object = CreateObject(spike, x+NUM, y, z-NUM, true, true, false)
Replace the two NUM
values with different values until you find one that spawns it in the best place for you.
Tried this but whenver i try to place the spikes i get this also when i drive a car over the spikes nothing popsā¦
`Command 'spike' entered..
Error running system event handling function for resource essentialmode: citizen:/scripting/lua/scheduler.lua:39: Failed to execute thread: citizen:/scripting/lua/MessagePack.lua:830: missing bytes
stack traceback:
[C]: in function 'error'
citizen:/scripting/lua/MessagePack.lua:830: in method 'underflow'
citizen:/scripting/lua/MessagePack.lua:465: in field 'any'
citizen:/scripting/lua/MessagePack.lua:860: in field 'unpack'
citizen:/scripting/lua/scheduler.lua:338: in field 'cmd'
server/main.lua:109: in upvalue 'handler'
citizen:/scripting/lua/scheduler.lua:124: in function <citizen:/scripting/lua/scheduler.lua:123>
stack traceback:
[C]: in function 'error'
citizen:/scripting/lua/scheduler.lua:39: in field 'CreateThreadNow'
citizen:/scripting/lua/scheduler.lua:123: in function <citizen:/scripting/lua/scheduler.lua:92>
hitch warning: frame time of 340 milliseconds
Command 'spike' entered..
Error running system event handling function for resource essentialmode: citizen:/scripting/lua/scheduler.lua:39: Failed to execute thread: citizen:/scripting/lua/MessagePack.lua:830: missing bytes
stack traceback:
[C]: in function 'error'
citizen:/scripting/lua/MessagePack.lua:830: in method 'underflow'
citizen:/scripting/lua/MessagePack.lua:465: in field 'any'
citizen:/scripting/lua/MessagePack.lua:860: in field 'unpack'
citizen:/scripting/lua/scheduler.lua:338: in field 'cmd'
server/main.lua:109: in upvalue 'handler'
citizen:/scripting/lua/scheduler.lua:124: in function <citizen:/scripting/lua/scheduler.lua:123>
stack traceback:
[C]: in function 'error'
citizen:/scripting/lua/scheduler.lua:39: in field 'CreateThreadNow'
citizen:/scripting/lua/scheduler.lua:123: in function <citizen:/scripting/lua/scheduler.lua:92>`
Any chance you know what the code would be for a vRP police officer?
i want people to read and understand the code not just download and move over and run and forget, but if people dont want to do that then thats fine but you dont learn that way.
thats the reason for this post for people to learn to gain more knowledge
nice point out :d yea i did a bobo on spelling not anything bad
I think its the limitation of the server it self worked flowless on old server like i says was not tested on new FX server so maybe server still needs more work
I completely see where youāre coming from. I think the faster people can jump right in the quicker they can make something great. Thereās already been people asking about positioning the objects differently and the like, so Iād say theyāre still getting to know the scripts.
Hopefully awesome scripts like this can inspire them to develop their own.
But that will only work for one direction
so basically you are telling me to go F*** myself?
I dont believe he said thatā¦
Maybe I am missing something, But everything I have tried to get this script to work on my FX server it just wont do anything. /spikes or /spike I forget now , but nothing happens. I had to start over sence the older server wont Work anymore so I am new to the FX server thing.
This should be working fine for you. As this works on my FXServer. Just as long as you have added to your server.cfg to start up on server start up then it should be working for you. Just as long as you downloaded the FX version and not the Essential mode version. Download FX version here
First off, let me say, thanks so much for sharing this script! Itās absolutely amazing having a spike strip option in a police roleplay server.
I wanted an option to delete the spikes if they were placed incorrectly, such as too far off the side of the road or pointing the wrong direction. This is the first time, Iāve even attempted to make a function call in a lua script, so there may be a better way, but this appears to work for me, so far. Hope it helps others:
In client.lua, add the following after the RegisterNetEvent(āc_setSpikeā) function:
RegisterNetEvent('c_deleteSpike')
AddEventHandler('c_deleteSpike', function()
DeleteSpike()
end)
Also in client.lua, at the very bottom, add this:
function DeleteSpike()
local ped = GetPlayerPed(-1)
local pedCoord = GetEntityCoords(ped)
if DoesObjectOfTypeExistAtCoords(pedCoord["x"], pedCoord["y"], pedCoord["z"], 0.9, GetHashKey("P_ld_stinger_s"), true) then
spike = GetClosestObjectOfType(pedCoord["x"], pedCoord["y"], pedCoord["z"], 0.9, GetHashKey("P_ld_stinger_s"), false, false, false)
SetEntityAsMissionEntity(spike, true, true)
DeleteObject(spike)
end
end
In server.lua, add this at the bottom:
AddEventHandler('chatMessage', function(source, n, msg) -- usage /nospike in chat to remove spike strip
msg = string.lower(msg)
if (msg == "/nospike") then
CancelEvent()
TriggerClientEvent('c_deleteSpike', source)
end
end)
@OnyxEye Thanks for the update. 5 times I did the /nospike and it deleted the spikes This is a great addition to the script