JuniorMelo Posted September 26, 2013 Share Posted September 26, 2013 Hello I have a problem with this script When the player dies in a car does not count EXP function win(ammo, killer, weapon, bodypart) local killer1 = getPlayerName(killer) local name = getPlayerName(source) if (killer and killer ~= source) then if (getElementType(killer) == "vehicle") then killer = getVehicleController(killer) end if (killer) then triggerClientEvent(killer, "exp", getRootElement()) end end end addEventHandler( "onPlayerWasted", getRootElement(), win) sorry my bad english Link to comment
3NAD Posted September 26, 2013 Share Posted September 26, 2013 Try this. function win ( ammo, killer, weapon, bodypart ) if killer then if getElementType ( killer ) == "player" then if killer ~= source then triggerClientEvent ( killer, "exp", root ) end elseif getElementType ( killer ) == "vehicle" then local killer = getVehicleOccupant ( killer, 0 ) if killer then triggerClientEvent ( killer, "exp", root ) end end end end addEventHandler ( "onPlayerWasted", root, win ) Link to comment
JuniorMelo Posted September 26, 2013 Author Share Posted September 26, 2013 Try this. function win ( ammo, killer, weapon, bodypart ) if killer then if getElementType ( killer ) == "player" then if killer ~= source then triggerClientEvent ( killer, "exp", root ) end elseif getElementType ( killer ) == "vehicle" then local killer = getVehicleOccupant ( killer, 0 ) if killer then triggerClientEvent ( killer, "exp", root ) end end end end addEventHandler ( "onPlayerWasted", root, win ) sorry, is not what i wanted when another player is in a vehicle not count EXP function win ( ammo, killer, weapon, bodypart ) if killer then if getElementType ( killer ) == "player" then if killer ~= source then triggerClientEvent ( killer, "exp", root ) end elseif getElementType ( source ) == "vehicle" then local source = getVehicleOccupant ( source, 0 ) if source then triggerClientEvent ( source, "exp", root ) end end end end addEventHandler ( "onPlayerWasted", root, win ) Link to comment
3NAD Posted September 26, 2013 Share Posted September 26, 2013 I don't understand what do you wanna to do, Explain more ... Link to comment
Moderators IIYAMA Posted September 26, 2013 Moderators Share Posted September 26, 2013 if #getVehicleOccupants (source ) == 0 then ? Link to comment
JuniorMelo Posted September 27, 2013 Author Share Posted September 27, 2013 I don't understand what do you wanna to do, Explain more ... I'm trying to do the following I and another player are using the hunter, I kill the other player but not gain EXP Link to comment
3NAD Posted September 27, 2013 Share Posted September 27, 2013 I think you need to this: getElementModel -- hunter ID getVehicleOccupant or getVehicleController Link to comment
JuniorMelo Posted September 27, 2013 Author Share Posted September 27, 2013 I will test this * killer * and who kills * source * and who died right ??? Link to comment
Moderators IIYAMA Posted September 27, 2013 Moderators Share Posted September 27, 2013 yes, correct. Link to comment
JuniorMelo Posted September 27, 2013 Author Share Posted September 27, 2013 then, because this line does not work ?? elseif getElementType ( source ) == "vehicle" then local source = getVehicleOccupant ( source, 0 ) if source then triggerClientEvent ( source, "exp", root ) end Link to comment
Moderators IIYAMA Posted September 27, 2013 Moderators Share Posted September 27, 2013 what doesn't work about it? Explosions aren't damage cause of the vehicle. Only when you ram a player with it, it will be the vehicle. Link to comment
JuniorMelo Posted September 27, 2013 Author Share Posted September 27, 2013 you mean it is not possible to do this? what doesn't work about it?Explosions aren't damage cause of the vehicle. Only when you ram a player with it, it will be the vehicle. Link to comment
Moderators IIYAMA Posted September 27, 2013 Moderators Share Posted September 27, 2013 Nothing is impossible, my server is already using a system that can do that or even more. But I won't start talking about that because you simply can't use my property... What you can try is using the event's to save the last vehicle etc. https://wiki.multitheftauto.com/wiki/OnVehicleEnter https://wiki.multitheftauto.com/wiki/OnVehicleExit https://wiki.multitheftauto.com/wiki/OnVehicleExplode If you really want to create something like that, You have to create your own system to manage the data, you can choose for elementdata or using tables for quick data usage. If you can work with tables, use tables cause they are 1000+ times faster with data then elementdata. Good luck cause you still have a long way to go for perfection. Link to comment
kevenvz Posted September 28, 2013 Share Posted September 28, 2013 You are redefining source and killer... 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