Tr0JaNz0r Posted January 1, 2013 Share Posted January 1, 2013 Hello everyone!, First of all Happy new year Okey, from 4 days ago i bought my new server and i was going to use it as a race server but i wanted to add some thing that are difficult and a (little bit) new but i had some problems while scripting it. well i was trying to make a script which gets the player name you got killed from or last damage i wanted to use it in my race server and to attach it between the killmessages on the left of the screen. but i didn't know which function or event i should i use, i searched the whole wiki upside down.. D: Well, maybe some one could help me in that! also i have problems in acvhivments i wanted to add it to my userpanel! Hope you can help me in that! Best wishes, Tr0JaN Link to comment
GhostXoP Posted January 1, 2013 Share Posted January 1, 2013 https://wiki.multitheftauto.com/wiki/OnClientPedDamage https://wiki.multitheftauto.com/wiki/OnClientPedWasted Link to comment
Tr0JaNz0r Posted January 1, 2013 Author Share Posted January 1, 2013 Umm thanks for that but maybe you didn't understand me well or maybe i didn't understand what do you mean lul. but i On Client ped damage it does only works on body parts?, what i mean that i have a DD server and when he gets killed by someone show his name... so it stands on (vehicles) now. i want something like get the last name hit your car. if you know what i mean? ;p Link to comment
GhostXoP Posted January 1, 2013 Share Posted January 1, 2013 https://wiki.multitheftauto.com/wiki/OnC ... eCollision The First argument is the element that hit the vehicle, can be another vehicle, and from there you can find out who was driving the vehicle that hit your vehicle (source) causing damage. Otherwise that's it afaik Link to comment
Tr0JaNz0r Posted January 1, 2013 Author Share Posted January 1, 2013 I understand your meaning, but i don't understand that.. usually examples helps me.. but i can't understand it.. maybe you can help me by creating a simple code? please :3 Link to comment
GhostXoP Posted January 1, 2013 Share Posted January 1, 2013 I do not believe code examples will help you with future learning of the events and/or functions. Hows this: This event will trigger when any element hits my car By reading the event, i understand that the car that hit me (or the ped) is the First argument. The source, is a car. The source however could be ANY CAR. you can check if this is your car by doing if ( source == getPedOccupiedVehicle(localPlayer) ) Or when setting the event handler do addEventHandler("onClientVehicleCollision", MyCar, function(carThatHitMe, so on and so forth) Then you can find out who is in the car (If its a car that hit you) on the first argument sent to your handler function, by using https://wiki.multitheftauto.com/wiki/GetVehicleOccupant Link to comment
Tr0JaNz0r Posted January 1, 2013 Author Share Posted January 1, 2013 Okey so that event. works on vehicle hits too not just peds, right? Link to comment
GhostXoP Posted January 1, 2013 Share Posted January 1, 2013 Works if anything hits your car. So the element can be a ped, but dont get confused here If its a ped driving a car, and their car hits you, it will be their car. If its some angry ped with a golf club, its going to be the angry ped with a gold club Link to comment
Tr0JaNz0r Posted January 1, 2013 Author Share Posted January 1, 2013 Okey sorry, but i understand till when the vehicle get's damaged the part that i don't.. that how to get the play name who hit my car?? and i want to output his name when the car health is 0 Link to comment
GhostXoP Posted January 1, 2013 Share Posted January 1, 2013 getPlayerName() getVehicleOccupant(VehicleThatHitYou) Make sure to check if the Element that hit you Is indeed a vehicle. As for everything else, i can help you learn how, not do it for you. Link to comment
Tr0JaNz0r Posted January 1, 2013 Author Share Posted January 1, 2013 What about this function playerDamage_text ( attacker, driver ) --when a player is damaged local driver = getVehicleOccupant ( source ) -- get the player sitting in seat 0 if ( attacker ) then local tempString if ( getElementType ( attacker ) == "vehicle" ) then local tempString = getPlayerName ( getVehicleController ( attacker ) ).." killed "..getPlayerName ( source ).." end end addEventHandler ( "onPlayerDamage", getRootElement (), playerDamage_text ) addEventHandler ( "onPlayerWasted", getRootElement(), player_Wasted ) Link to comment
Anderl Posted January 1, 2013 Share Posted January 1, 2013 You simply copied parts of codes from the wiki. 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