Wisin Posted September 28, 2010 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
dzek (varez) Posted September 28, 2010 Posted September 28, 2010 addEventHandler() OnPickupHit - event getElementData() getPlayerTeam() getTeamName() now check if name equals to name from element data if no - cancelEvent() Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
Wisin Posted September 28, 2010 Author 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?
dzek (varez) Posted September 28, 2010 Posted September 28, 2010 source of onPickupHit event (the pickup element)... Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
Wisin Posted September 28, 2010 Author Posted September 28, 2010 source of onPickupHit event (the pickup element)... Thank you varez its working
dzek (varez) Posted September 28, 2010 Posted September 28, 2010 your welcome Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
Wisin Posted September 28, 2010 Author 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);
dzek (varez) Posted September 28, 2010 Posted September 28, 2010 post your script for limiting pickups to team only Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
50p Posted September 28, 2010 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. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
Wisin Posted September 28, 2010 Author 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.
50p Posted September 28, 2010 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) - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
dzek (varez) Posted September 28, 2010 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.. Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
50p Posted September 28, 2010 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. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
dzek (varez) Posted September 28, 2010 Posted September 28, 2010 nonono, MONEY pickups. they are created in script above (7th post). Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
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