Blueman Posted June 27, 2011 Share Posted June 27, 2011 I'm making an rpg game mode but the blips and pickups for this specific code won't show it seems. My code: function main() medicblip = createBlip ( 2036, -1408, 17, 22, 0, 0, 0, 255 ) medicpickup = createPickup (2036, -1408, 17, 3, 1277, 100) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), displayLoadedRes ) addEventHandler ("onPickupUse", getRootElement(), function (playerWhoUses) if (source == medicpickup) then giveWeapon (playerWhoUses, 14, 1, true) setElementData (playerWhoUses, "job", "medic") else end end) addEventHandler ("onPlayerDamage", getRootElement(), function(attacker, weapon, bodypart, loss) if (weapon == 15) and getElementData ( attacker, "job" == "medic" )then setElementHealth ( targetPlayer, getElementHealth(targetPlayer) + 10 ) givePlayerMoney ( attacker, 450 ) cancelEvent() else end end Link to comment
CowTurbo Posted June 27, 2011 Share Posted June 27, 2011 (edited) function main() medicblip = createBlip ( 2036, -1408, 17, 22, 0, 0, 0, 255 ) medicpickup = createPickup (2036, -1408, 17, 3, 1277, 100) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), main) -- why is here displayLoadedRes, in ur script is no such function. addEventHandler ("onPickupUse", getRootElement(), function (playerWhoUses) if (source == medicpickup) then giveWeapon (playerWhoUses, 14, 1, true) setElementData (playerWhoUses, "job", "medic") else end end) addEventHandler ("onPlayerDamage", getRootElement(), function(attacker, weapon, bodypart, loss) if (weapon == 15) and getElementData ( attacker, "job" == "medic" )then setElementHealth ( targetPlayer, getElementHealth(targetPlayer) + 10 ) givePlayerMoney ( attacker, 450 ) cancelEvent() else end end Edited June 27, 2011 by Guest Link to comment
JR10 Posted June 27, 2011 Share Posted June 27, 2011 function main() medicblip = createBlip ( 2036, -1408, 17, 22, 0, 0, 0, 255 ) medicpickup = createPickup (2036, -1408, 17, 3, 1277, 100) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), main) addEventHandler ("onPickupUse", getRootElement(), function (playerWhoUses) if (source == medicpickup) then giveWeapon (playerWhoUses, 14, 1, true) setElementData (playerWhoUses, "job", "medic") else end end) addEventHandler ("onPlayerDamage", getRootElement(), function(attacker, weapon, bodypart, loss) if (weapon == 15) and getElementData ( attacker, "job" == "medic" )then setElementHealth ( targetPlayer, getElementHealth(targetPlayer) + 10 ) givePlayerMoney ( attacker, 450 ) cancelEvent() else end end Link to comment
Kenix Posted June 27, 2011 Share Posted June 27, 2011 (edited) Why targetPlayer ? Is nil in event onPlayerDamage server side function main() medicblip = createBlip ( 2036, -1408, 17, 22, 0, 0, 0, 255 ) medicpickup = createPickup (2036, -1408, 17, 3, 1277, 100) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), main) addEventHandler ("onPickupUse", getRootElement(), function (playerWhoUses) if source == medicpickup then giveWeapon (playerWhoUses, 14, 1, true) setElementData (playerWhoUses, "job", "medic") end end) client side addEventHandler ("onClientPlayerDamage", getRootElement(), function(attacker, weapon, bodypart, loss) if (weapon == 15) and getElementData ( attacker, "job" == "medic" )then setElementHealth ( source, getElementHealth(source) + 10 ) givePlayerMoney ( attacker, 450 ) cancelEvent() end end) Edited June 27, 2011 by Guest Link to comment
Castillo Posted June 27, 2011 Share Posted June 27, 2011 Note from the wiki: It should also be noted that canceling this event has no effect. Cancel the client-side event onClientPlayerDamage instead. 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