zzx Posted April 17, 2014 Share Posted April 17, 2014 I made a script, if anyone killed another player with his hunter, he will get 200$ but only with hunter. local reward = 200 function kill ( ammo, killer, killerweapon, bodypart ) local vehicle = getPedOccupiedVehicle ( killer ) if isPedInVehicle ( killer ) and getElementModel ( vehicle ) == 425 then givePlayerMoney ( source, reward ) outputChatBox ("#ff8800[REWARD] #ffffffYou have killed "..getPlayerName..( source )" ..and rewarded $".. tostring ( reward ), root, 0, 255, 0, true ) end end addEventHandler ( "onPlayerWasted", getRootElement(), kill ) help please Link to comment
-.Paradox.- Posted April 17, 2014 Share Posted April 17, 2014 local reward = 200 function kill ( ammo, killer, killerweapon, bodypart ) local vehicle = getPedOccupiedVehicle ( killer ) local veh = getVehicleID(vehicle) if isPedInVehicle ( killer ) and veh == 425 then givePlayerMoney ( killer, reward ) outputChatBox ("#ff8800[REWARD] #ffffffYou have killed "..getPlayerName..( source )" ..and rewarded $".. tostring ( reward ), killer, 0, 255, 0, true ) end end addEventHandler ( "onPlayerWasted", getRootElement(), kill ) Link to comment
Tete omar Posted April 17, 2014 Share Posted April 17, 2014 local reward = 200 function kill ( ammo, killer, killerweapon, bodypart ) local vehicle = getPedOccupiedVehicle ( killer ) local veh = getVehicleID(vehicle) if isPedInVehicle ( killer ) and veh == 425 then givePlayerMoney ( killer, reward ) outputChatBox ("#ff8800[REWARD] #ffffffYou have killed "..getPlayerName..( source )" ..and rewarded $".. tostring ( reward ), killer, 0, 255, 0, true ) end end addEventHandler ( "onPlayerWasted", getRootElement(), kill ) This won't work, first, getVehicleID is a deprecated function, second, you're defining the vehicle without checking whether the killer is a player. This should work i guess: local reward = 200 function kill ( ammo, killer, killerweapon, bodypart ) if ( getElementType ( killer ) == "vehicle" ) then if ( getElementModel ( killer ) == 425 ) then local controller = getVehicleController ( killer ) givePlayerMoney ( controller, reward ) outputChatBox ("#ff8800[REWARD] #ffffffYou have killed " .. getPlayerName ( source ) .. " and rewarded $" .. reward, controller, 255, 255, 255, true ) end end end addEventHandler ( "onPlayerWasted", getRootElement(), kill ) Link to comment
-.Paradox.- Posted April 17, 2014 Share Posted April 17, 2014 local reward = 200 function kill ( ammo, killer, killerweapon, bodypart ) local vehicle = getPedOccupiedVehicle ( killer ) local veh = getVehicleID(vehicle) if isPedInVehicle ( killer ) and veh == 425 then givePlayerMoney ( killer, reward ) outputChatBox ("#ff8800[REWARD] #ffffffYou have killed "..getPlayerName..( source )" ..and rewarded $".. tostring ( reward ), killer, 0, 255, 0, true ) end end addEventHandler ( "onPlayerWasted", getRootElement(), kill ) This won't work, first, getVehicleID is a deprecated function, second, you're defining the vehicle without checking whether the killer is a player. This should work i guess: local reward = 200 function kill ( ammo, killer, killerweapon, bodypart ) if ( getElementType ( killer ) == "vehicle" ) then if ( getElementModel ( killer ) == 425 ) then local controller = getVehicleController ( killer ) givePlayerMoney ( controller, reward ) outputChatBox ("#ff8800[REWARD] #ffffffYou have killed " .. getPlayerName ( source ) .. " and rewarded $" .. reward, controller, 255, 255, 255, true ) end end end addEventHandler ( "onPlayerWasted", getRootElement(), kill ) My bad, this one should work yeah. Link to comment
Moderators IIYAMA Posted April 17, 2014 Moderators Share Posted April 17, 2014 Note: Check if there is a controller, it can be none. Link to comment
Tete omar Posted April 17, 2014 Share Posted April 17, 2014 Yeah, i thought of that, but the hunter can never be without a controller when it kills someone, that's impossible Link to comment
Moderators IIYAMA Posted April 17, 2014 Moderators Share Posted April 17, 2014 Yeah, i thought of that, but the hunter can never be without a controller when it kills someone, that's impossible You sure about that? local vehicles = getElementsByType("vehicle") for i=1, #vehicles do local vehicle = vehicles[i] setElementVelocity ( vehicle,0,0, 30 ) end setTimer(function() local vehicles = getElementsByType("vehicle") for i=1, #vehicles do local vehicle = vehicles[i] setElementVelocity ( vehicle,0,0, -30 ) end end,1000,1) If you have low hp and you get rammed by a falling hunter? Link to comment
Tete omar Posted April 17, 2014 Share Posted April 17, 2014 If you have low hp and you get rammed by a falling hunter? Which is probably too rare to be happened Link to comment
zzx Posted April 17, 2014 Author Share Posted April 17, 2014 I already kept tete's code, anyhow thanks to everyone. Link to comment
-.Paradox.- Posted April 17, 2014 Share Posted April 17, 2014 My code had many mistakes, I'm glad that Tete fixed it. You're welcome anyway. 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