glowdemon1 Posted February 6, 2014 Share Posted February 6, 2014 Hi, I've got some code but unfortunately it doesn't work. Whenever I execute printNearbyPeds (line 58) it unfortunately wont work. There's nothing much to say. I've checked if the elementdata actualy did get stored etc which they actualy do. http://paste.ofcode.org/zf3KfJYMMXQyFFXJ5XUAZ5 , hoping that somebody is able to find my error. Link to comment
myonlake Posted February 6, 2014 Share Posted February 6, 2014 Remove cindex from getNearbyCorpses. Arrays are automatically pushed and you won't have to define the key manually. If you want to erase the array, you can just empty the array with curly brackets, but as the array is defined locally, you won't have to worry about erasing anything. This might be the solution for the issue. Also, when you incremented cindex variable, it was set to local, so it never actually increased the value because it was unset after the round was completed. Link to comment
glowdemon1 Posted February 7, 2014 Author Share Posted February 7, 2014 snip thanks for the reply. I've tried this and didn't work, I decided to leave some checks to get some errors and it keeps on saying that getElementData retrieves a nil value. : currentID = 0 function spawnPedUponDead() local pedSkin = getElementModel(source) local x,y,z = getElementPosition(source) local _,_,rz = getElementRotation(source) local ped = createPed(pedSkin,x,y,z,rz,false) if ped then local data = setElementData(ped,"ped_id",curentID) setElementData(ped,"ped_type","deadcorpse") setElementData(ped,"postmortum",getPlayerName(source)) killPed(ped) if data then outputChatBox(currentID..getElementData(ped,"ped_id")..getElementData(ped,"postmortum")) currentID = currentID + 1 end end end addEventHandler("onPlayerWasted",root,spawnPedUponDead) Link to comment
myonlake Posted February 7, 2014 Share Posted February 7, 2014 You don't need the data check. Also, you have a typo in the setElementData part. setElementData(ped,"ped_id",curentID) 'curentID' should be 'currentID'. Remove the 'local data' part as well, it doesn't return anything except a boolean and it always returns true as long as your arguments are valid, which in this case are not, because of the typo. Link to comment
glowdemon1 Posted February 7, 2014 Author Share Posted February 7, 2014 You don't need the data check. Also, you have a typo in the setElementData part. setElementData(ped,"ped_id",curentID) 'curentID' should be 'currentID'. Remove the 'local data' part as well, it doesn't return anything except a boolean and it always returns true as long as your arguments are valid, which in this case are not, because of the typo. Mh alrighty, thanks for the help. Works fine now, didn't even see the typo. Link to comment
myonlake Posted February 7, 2014 Share Posted February 7, 2014 You're welcome. The biggest issue in the world of programming are the smallest mistakes we make. I've spent days trying to find out a reason for a problem myself in Ajax and PHP data transfer, there are no errors either even though all debugs are on and logging, still no errors outputted, so yep, it's always good for someone else to have a look at the code because people spot different type of things. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now