Wisin Posted September 28, 2010 Share Posted September 28, 2010 hello all, i made a map file which containts pickups and i want to restrict them to a team expecified, so i did, <pickup id="pickup (health) (1)" type="health" interior="0" amount="100" respawn="30000" dimension="0" posX="1665.3149414063" posY="-1909.2155761719" posZ="21.954151153564" rotX="0" rotY="0" rotZ="0" team="Chinese" /> but now i don't know how to check that team and if matches with player team he can pick it else it will cancel the event, if someone can tell me how. thanks Link to comment
dzek (varez) Posted September 28, 2010 Share Posted September 28, 2010 addEventHandler() OnPickupHit - event getElementData() getPlayerTeam() getTeamName() now check if name equals to name from element data if no - cancelEvent() Link to comment
Wisin Posted September 28, 2010 Author Share Posted September 28, 2010 addEventHandler()OnPickupHit -- event getElementData() getPlayerTeam() getTeamName() now check if name equals to name from element data if no - cancelEvent() ok but from what i get the element data? Link to comment
dzek (varez) Posted September 28, 2010 Share Posted September 28, 2010 source of onPickupHit event (the pickup element)... Link to comment
Wisin Posted September 28, 2010 Author Share Posted September 28, 2010 source of onPickupHit event (the pickup element)... Thank you varez its working Link to comment
Wisin Posted September 28, 2010 Author Share Posted September 28, 2010 i've found a problem, i got a money drop script but i think this other pickups for teams is messing with it, here is my money drop script function createMoney(player) local x, y, z = getElementPosition(player); local x1, y1, x2, y2; x1 = (x-2)+(math.random()*4); y1 = (y-2)+(math.random()*4); x2 = (x-2)+(math.random()*4); y2 = (y-2)+(math.random()*4); local moneyAmmount = getPlayerMoney(player); -- it is not fair too get all the player money. moneyAmmount = math.floor(moneyAmmount/1); takePlayerMoney(player, moneyAmmount); -- We are going to create 2 pickups, zo we are just cut the ammount in half moneyAmmount = math.floor(moneyAmmount/2); -- Create the pickups setElementData(createPickup(x1, y1, z, 3, 1212), "ammount", moneyAmmount); setElementData(createPickup(x2, y2, z, 3, 1212), "ammount", moneyAmmount); end function moneyPickupHit(player) local money = getElementData(source, "ammount"); if money then givePlayerMoney(player, money); destroyElement(source); end end function playerJustGotDied(ammo, attacker, weapon, bodypart) createMoney(source); end addEventHandler("onPickupUse", getRootElement(), moneyPickupHit); addEventHandler("onPlayerWasted", getRootElement(), playerJustGotDied); Link to comment
dzek (varez) Posted September 28, 2010 Share Posted September 28, 2010 post your script for limiting pickups to team only Link to comment
50p Posted September 28, 2010 Share Posted September 28, 2010 i've found a problem, i got a money drop script but i think this other pickups for teams is messing with it, here is my money drop script ... Very informative. Link to comment
Wisin Posted September 28, 2010 Author Share Posted September 28, 2010 function onUse(hitPlayer) local team = getPlayerTeam(hitPlayer) local teamName = getTeamName(team) local eleData = getElementData(source,"team") if eleData == teamName then else cancelEvent() end end addEventHandler("onPickupHit",getRootElement(),onUse) thats it. Link to comment
50p Posted September 28, 2010 Share Posted September 28, 2010 You can check if the hit pickup is a money pickup before you cancel event. Something like this: function onUse(hitPlayer) local teamName = getTeamName( getPlayerTeam( hitPlayer ) ) local eleData = getElementData(source,"team") if ( eleData ~= teamName ) and ( getElementModel( source ) ~= 1212 ) then -- 1212 or whatever model ID is your money pickup cancelEvent() end end addEventHandler("onPickupHit",getRootElement(),onUse) Link to comment
dzek (varez) Posted September 28, 2010 Share Posted September 28, 2010 i dont see any "team" element data in his money pickups script.. shouldnt this eleData == teamName fail when picked up money pickup then? eleData will be false, team name probably something else.. Link to comment
50p Posted September 28, 2010 Share Posted September 28, 2010 You can't see it because it's in the map file that he showed in the first post that you probably forgot about. Link to comment
dzek (varez) Posted September 28, 2010 Share Posted September 28, 2010 nonono, MONEY pickups. they are created in script above (7th post). Link to comment
Wisin Posted September 28, 2010 Author Share Posted September 28, 2010 ok it works, thank you. 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