BieHDC Posted August 28, 2013 Share Posted August 28, 2013 Hello, i wanna give the Server 2 elements, but only the 1st is sent sucsessfully. Outputs: server line 4 > bad argument @ getvehicleaccupant --clientside function collision ( thehitted ) if thehitted and getElementType ( thehitted ) == "vehicle" then if ( source == getPedOccupiedVehicle(getLocalPlayer()) ) then triggerServerEvent ( "whowasit", source, thehitted ) end end end addEventHandler("onClientVehicleCollision", root, collision) --serverside function whokilledvic ( thehitter, thehitted ) local hitterp = getPlayerName(getVehicleOccupant( thehitter )) local hittedp = getPlayerName(getVehicleOccupant( thehitted )) setVehicleColor ( thehitter , 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255 ) outputChatBox( hitterp.. " > hitted > " ..hittedp, root ) end addEvent ( "whowasit", true ) addEventHandler ( "whowasit", root, whokilledvic ) Link to comment
golanu21 Posted August 28, 2013 Share Posted August 28, 2013 triggerServerEvent ( "whowasit", source) not tested Link to comment
Moderators IIYAMA Posted August 28, 2013 Moderators Share Posted August 28, 2013 --serverside function whokilledvic ( thehitted ) local thehitter = source local hitterp = getPlayerName(getVehicleOccupant( thehitter )) local hittedp = getPlayerName(getVehicleOccupant( thehitted )) setVehicleColor ( thehitter , 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255 ) outputChatBox( hitterp.. " > hitted > " ..hittedp, root ) end addEvent ( "whowasit", true ) addEventHandler ( "whowasit", root, whokilledvic ) theElement: The element that is the source of the event. This could be another player, or if this isn't relevant, use the root element. triggerServerEvent ( string event, element theElement, [arguments...] ) Link to comment
BieHDC Posted August 28, 2013 Author Share Posted August 28, 2013 thx now it works and i gained a bit more experience ^ Link to comment
Moderators IIYAMA Posted August 28, 2013 Moderators Share Posted August 28, 2013 np. btw something I did noticed about this event. The event onClientVehicleCollision can be triggered a lot (just for a single scratch), if this player may have bad connection there is a chance that he will be timed out very quickly. So I recommend you to choose for a minimal force before sending info to the server. element theHitElement, float force, int bodypart, float collisionX, float collisionY, float collisionZ, float normalX, float normalY, float normalZ, float hitElementForce, int model Link to comment
BieHDC Posted August 28, 2013 Author Share Posted August 28, 2013 i already noticed that and have done the following: and it works function collision ( thehitted ) if hit == "false" then if thehitted and getElementType ( thehitted ) == "vehicle" then if ( source == getPedOccupiedVehicle(getLocalPlayer()) ) then thehitted2 = thehitted triggerServerEvent ( "whowasit", source, thehitted2 ) hit = "true" setTimer( resethittimer, 5000, 1 ) end end end end addEventHandler("onClientVehicleCollision", root, collision) function resethittimer() hit = "false" end Link to comment
Moderators IIYAMA Posted August 28, 2013 Moderators Share Posted August 28, 2013 I will recommend you only use timers, when there is no other way. If you want to go for performance then: local lastHit = getTickCount() local function collision ( thehitted ) local tickTime = getTickCount() if thehitted and tickTime > lastHit and getElementType ( thehitted ) == "vehicle" then if source == getPedOccupiedVehicle(getLocalPlayer()) then thehitted2 = thehitted triggerServerEvent ( "whowasit", source, thehitted2 ) lastHit = tickTime+1000 end end end addEventHandler("onClientVehicleCollision", root, collision) Use gametime(getTickCount()) to check if amount of time has been past. isn't 5 seconds very long? This is for DD right? Link to comment
BieHDC Posted August 28, 2013 Author Share Posted August 28, 2013 thx for the "better" code^ EDIT: it works its a special DD, a revolution One is Victim and the others have to catch him. If the victim hits a colsphere he wins and so on... And yes its long, but what would be the right...if 1 sec then its flooding > think about if 20 players are messing around with one victim and if the script is ready i will post in showcase and maybe you wanna develop with me if you think its a good one^ because i wrote it in noob style, because i am a beginner and i would need someone who can help me to unmess the code Link to comment
Moderators IIYAMA Posted August 28, 2013 Moderators Share Posted August 28, 2013 interesting idea, It is your idea so you should development it in the first place, if there are any problems you can pm me any time. (my response is sometimes quick and sometimes it can take 1/2 days) I wish you good luck! Link to comment
BieHDC Posted August 28, 2013 Author Share Posted August 28, 2013 have you also skype? and thx^ and if you have ideas what i can built in, then tell me^ Link to comment
EstrategiaGTA Posted August 29, 2013 Share Posted August 29, 2013 have you also skype?and thx^ and if you have ideas what i can built in, then tell me^ How do you mean? 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