John Smith Posted August 23, 2014 Share Posted August 23, 2014 hi i just wanted to try out this function but i dont know what im doing wrong function createColField(thePlayer) local x,y,z = getElementPosition(thePlayer) createColSphere(x,y,z,20) outputChatBox(tonumber(x)..tonumber(y)..tonumber(z),thePlayer) end addCommandHandler("col_field",createColField) i set development mode with crun command and i used showcol command and in debugscript 3 no errors it outputs x,y,z but i dont see any collision thingy please help Link to comment
lcd12321 Posted August 23, 2014 Share Posted August 23, 2014 try to check whats return createcolsphere Link to comment
John Smith Posted August 23, 2014 Author Share Posted August 23, 2014 how do i do that?im new to this col function idk sry edit: not sure if this can be a way to do it but i tried this colshape = createColSphere(x,y,z,2) outputChatBox(tostring(colshape)) it outputted userdata: 000000000000CE31 Link to comment
lcd12321 Posted August 23, 2014 Share Posted August 23, 2014 if returned userdata it's mean that colsphere created. So maybe u setdevmode after command showcol. Write what console is writing after command showcol 1 Link to comment
ma2med Posted August 23, 2014 Share Posted August 23, 2014 It's work for me, did you put "setDevelopmentMode" in client ? Link to comment
John Smith Posted August 23, 2014 Author Share Posted August 23, 2014 here are exact steps how i did this Executing client-side command: setDevelopmentMode(true) Command results: true [boolean] restart: Resource restarting... showcol is now set to 0 showcol is now set to 1 -- command for colshape has been used in here -- output after command using: 1960.6787109375-2016.725585937513.3828125 (my coordinates) userdata: 0000000000013385 (colshape element created) however still not working Link to comment
Anubhav Posted August 23, 2014 Share Posted August 23, 2014 Can you see the boxes? FIND in SA. Link to comment
John Smith Posted August 23, 2014 Author Share Posted August 23, 2014 i cant see those green-red things at all, i said it already, i cant see them, thats the problem and reason why i made this topic Link to comment
Anubhav Posted August 23, 2014 Share Posted August 23, 2014 Try changing the size to '5000' And see if the green boxes appear. Link to comment
Anubhav Posted August 23, 2014 Share Posted August 23, 2014 Damn, keep increasing it then. Link to comment
John Smith Posted August 23, 2014 Author Share Posted August 23, 2014 i have restarted whole server and set size to 5 and now it works, but its something weird it makes sphere on my position(big one) and attaches smaller one behind me(football ball size) edit: also, is there a way how can i make that when specific element hits the col sphere, that it creates the collision and element can't pass through or gets damage? Link to comment
Anubhav Posted August 23, 2014 Share Posted August 23, 2014 (edited) addEventHandler("onColShapeHit", colshape, function(hit) local occupied = getPedOccupiedVehicle(hit) if hit then outputChatBox("You car will be destroyed within 5 secs! This area doesn't accept vehicles!", hit) setTimer(destroyVeh, 5000, 1, occupied) end setElementData(hit, "no-damage", true) end ) addEventHandler("onColShapeLeave", colshape, function(hit) removeElementData(hit, "no-damage") end ) addEventHandler("onPlayerDamage", root, function() if getElementData(hit, "no-damage") then cancelEvent() end end ) Edited August 23, 2014 by Guest Link to comment
John Smith Posted August 23, 2014 Author Share Posted August 23, 2014 thanks but i meant the opposite if player hits colshape or a vehicle, then it cant go through is it possible to make it that way? also for line 2,7 it outputs that 2nd argument is nil Link to comment
Anubhav Posted August 23, 2014 Share Posted August 23, 2014 See my edited post. And replace 'colshape' with your colshape variable. Link to comment
John Smith Posted August 23, 2014 Author Share Posted August 23, 2014 i renamed variable to 'ddd' and now at line 2 and 12 it says argument 2 element is nil because that function doesnt recognize 'ddd' variable, and if i place 'ddd' outisde of first function, it wont work at all also i doubt your destroyVeh function at setTimer would do anything as i don't see it anywhere defined Link to comment
Anubhav Posted August 23, 2014 Share Posted August 23, 2014 Replace it with resourceRoot it will work fine then. And change destroyVeh to destroyVehicle typo. Link to comment
John Smith Posted August 23, 2014 Author Share Posted August 23, 2014 bad argument 1 setTimer expected function at argument 1, got nil and it says "your vehicle will be destroyed..." as soon as resource starts, and not when vehicle gets into colshape Link to comment
Anubhav Posted August 23, 2014 Share Posted August 23, 2014 I am not sure what is wrong now :-/. Link to comment
Bonsai Posted August 23, 2014 Share Posted August 23, 2014 To both of you, the wiki is a powerful tool. That script doesn't check for the element type. It doesn't check if "occupied" is false or actually a car. Also I don't get the need of this "no-damage" thing. addEventHandler("onColShapeHit", colshape, function(hitElement) if not hitElement then return end if getElementType(hitElement) == "player" then hitElement = getPedOccupiedVehicle(hitElement) elseif getElementType(hitElement) ~= "vehicle" then return end end setElementVelocity(hitElement, 0, 0, 0) --maybe? Not sure what you want, try it out. Not sure if working with peds either. end ) Not tested. Link to comment
John Smith Posted August 23, 2014 Author Share Posted August 23, 2014 argument 2 is still nil addEventHandler("onColShapeHit", colshape, Link to comment
Bonsai Posted August 23, 2014 Share Posted August 23, 2014 Oh well yeah, the colshape that you are creating gotta have that name. Else you could also use root and check if source == your colshape in that function. Link to comment
John Smith Posted August 23, 2014 Author Share Posted August 23, 2014 yeah i could do all that magic, but theres still one problem and im trying to tell everyone 23101290 times about it that colshape variable is not defined in full script if i put it outside of every function(on top of script) not a single function will load it,idk why and if i put it in some function,only that function will be able to load it how do i define variable for whole script? (in this case 'ddd' variable which is that colshape element) ? Link to comment
Bonsai Posted August 23, 2014 Share Posted August 23, 2014 Visible for whole resource: ddd = true Visible for script file only: local ddd = true (unless its inside of a function, if statement etc.) Basically, "local" makes a variable be only visible and therefore existing within the scope it was defined in. 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