bradio10 Posted March 15, 2013 Share Posted March 15, 2013 Hi guys. I have used this to get my scripting only working for the people in this team and for some reason, it doesn't work and I have no clue why. At time to time, if I change something, somtimes I get a stack overflow Here is the script: Server: locations = { {459.93146, 888.78650, -27.64281}, {507.28488, 971.90436, -24.47141}, {664.53302, 721.46564, -4.02670}, } function create() local x, y, z = unpack ( locations [ math.random ( #locations ) ] ) if getTeamName (getPlayerTeam(thePlayer)) == "Workers" then marker = createMarker (x, y, z, "cylinder", 2, 255, 255, 0, 255) blip = createBlipAttachedTo( marker, 0, 2, 0, 250, 0, 170 ) end end addEventHandler ("onResourceStart", root, create) addEvent ("createLoc", true) addEventHandler ("createLoc", root, create) function onHit() if getTeamName (getPlayerTeam(thePlayer)) == "Workers" then triggerEvent ("pay", getRootElement(), onHit) destroyElement (blip) destroyElement (marker) triggerEvent ("createLoc", root, onHit) end end addEventHandler ("onMarkerHit", root, onHit) And yes, I have created the team, I just at the moment, need to set myself to it via the admin panel. function team() team = createTeam ("Workers", 255, 255, 0) end addEventHandler ("onResourceStart", resourceRoot, team) Thanks. Link to comment
Fury Posted March 15, 2013 Share Posted March 15, 2013 locations = { {459.93146, 888.78650, -27.64281}, {507.28488, 971.90436, -24.47141}, {664.53302, 721.46564, -4.02670}, } addEvent ("createLoc", true) addEventHandler ("createLoc", root, create) function create(thePlayer) -- you forget to define element local x, y, z = unpack ( locations [ math.random ( #locations ) ] ) if getTeamName (getPlayerTeam(thePlayer)) == "Workers" then marker = createMarker (x, y, z, "cylinder", 2, 255, 255, 0, 255) blip = createBlipAttachedTo( marker, 0, 2, 0, 250, 0, 170 ) end end addEventHandler ("onResourceStart", root, create) function onHit(thePlayer) -- you forget to define element if getTeamName (getPlayerTeam(thePlayer)) == "Workers" then triggerEvent ("pay", getRootElement(), onHit) destroyElement (blip) destroyElement (marker) triggerEvent ("createLoc", root, onHit) end end addEventHandler ("onMarkerHit", root, onHit) Link to comment
bradio10 Posted March 15, 2013 Author Share Posted March 15, 2013 locations = { {459.93146, 888.78650, -27.64281}, {507.28488, 971.90436, -24.47141}, {664.53302, 721.46564, -4.02670}, } addEvent ("createLoc", true) addEventHandler ("createLoc", root, create) function create(thePlayer) -- you forget to define element local x, y, z = unpack ( locations [ math.random ( #locations ) ] ) if getTeamName (getPlayerTeam(thePlayer)) == "Workers" then marker = createMarker (x, y, z, "cylinder", 2, 255, 255, 0, 255) blip = createBlipAttachedTo( marker, 0, 2, 0, 250, 0, 170 ) end end addEventHandler ("onResourceStart", root, create) function onHit(thePlayer) -- you forget to define element if getTeamName (getPlayerTeam(thePlayer)) == "Workers" then triggerEvent ("pay", getRootElement(), onHit) destroyElement (blip) destroyElement (marker) triggerEvent ("createLoc", root, onHit) end end addEventHandler ("onMarkerHit", root, onHit) Doesn't work. It says bad "player" pointer @ "getPlayerTeam" (1) Link to comment
Fury Posted March 15, 2013 Share Posted March 15, 2013 well you have to write element name at client side too. if you dont want you can use this one; locations = { {459.93146, 888.78650, -27.64281}, {507.28488, 971.90436, -24.47141}, {664.53302, 721.46564, -4.02670}, } addEvent ("createLoc", true) addEventHandler ("createLoc", root, create) function create() local x, y, z = unpack ( locations [ math.random ( #locations ) ] ) if getTeamName (getPlayerTeam(source)) == "Workers" then marker = createMarker (x, y, z, "cylinder", 2, 255, 255, 0, 255) blip = createBlipAttachedTo( marker, 0, 2, 0, 250, 0, 170 ) end end addEventHandler ("onResourceStart", root, create) function onHit() if getTeamName (getPlayerTeam(source)) == "Workers" then triggerEvent ("pay", getRootElement(), onHit) destroyElement (blip) destroyElement (marker) triggerEvent ("createLoc", root, onHit) end end addEventHandler ("onMarkerHit", root, onHit) Link to comment
bradio10 Posted March 15, 2013 Author Share Posted March 15, 2013 well you have to write element name at client side too. if you dont want you can use this one; locations = { {459.93146, 888.78650, -27.64281}, {507.28488, 971.90436, -24.47141}, {664.53302, 721.46564, -4.02670}, } addEvent ("createLoc", true) addEventHandler ("createLoc", root, create) function create() local x, y, z = unpack ( locations [ math.random ( #locations ) ] ) if getTeamName (getPlayerTeam(source)) == "Workers" then marker = createMarker (x, y, z, "cylinder", 2, 255, 255, 0, 255) blip = createBlipAttachedTo( marker, 0, 2, 0, 250, 0, 170 ) end end addEventHandler ("onResourceStart", root, create) function onHit() if getTeamName (getPlayerTeam(source)) == "Workers" then triggerEvent ("pay", getRootElement(), onHit) destroyElement (blip) destroyElement (marker) triggerEvent ("createLoc", root, onHit) end end addEventHandler ("onMarkerHit", root, onHit) Even with source, it still doesn't work. Link to comment
Baseplate Posted March 15, 2013 Share Posted March 15, 2013 locations = { {459.93146, 888.78650, -27.64281}, {507.28488, 971.90436, -24.47141}, {664.53302, 721.46564, -4.02670}, } addEvent ("createLoc", true) addEventHandler ("createLoc", root, create) function create() local x, y, z = unpack ( locations [ math.random ( #locations ) ] ) if getTeamName (getPlayerTeam(source)) == "Workers" then marker = createMarker (x, y, z, "cylinder", 2, 255, 255, 0, 255) blip = createBlipAttachedTo( marker, 0, 2, 0, 250, 0, 170 ) end end addEventHandler ("onResourceStart", root, create) function onHit(hitElement) if getElementType(hitElement) =="player" and getTeamName (getPlayerTeam(hitElement)) == "Workers" then triggerEvent ("pay", getRootElement(), onHit) destroyElement (blip) destroyElement (marker) triggerEvent ("createLoc", root, onHit) end end addEventHandler ("onMarkerHit", root, onHit) I'm suggesting to have a re-look on your script, it's a real mess and I just helped with your error... Link to comment
Fury Posted March 15, 2013 Share Posted March 15, 2013 this is working for me, you did mistake at onMarketHit event and function. you have to define the market at here; addEventHandler ("onMarkerHit", root, onHit) should be addEventHandler ("onMarkerHit", your-marker, onHit) Link to comment
Baseplate Posted March 15, 2013 Share Posted March 15, 2013 I didn't say it won't work, but he could make it in a better structure, cause trigger events like createLoc while he can just use createLoc() would cause some lag... Link to comment
bradio10 Posted March 15, 2013 Author Share Posted March 15, 2013 Ok, none of those fixed it and Fury, the reason why I have root, is because I am using a table, so if I put the marker name, it comes up with a bad argument. And Samer, the team thing didn't work. So here is my full script. Once this gets fixed, I will then make it abit neater like you said Samer. function giveMoney () cash = math.random (500, 1000) givePlayerMoney (source, cash) outputChatBox ( "You have just received $ " ..cash , source, 0, 255, 0, true) fadeCamera (source, false, 0.8, 0, 0, 0) setTimer ( fadeCamera, 3000, 1, source, true, 1 ) end addEvent ("pay", true) addEventHandler ("pay", root, giveMoney) locations = { {459.93146, 888.78650, -27.64281}, {507.28488, 971.90436, -24.47141}, {664.53302, 721.46564, -4.02670}, } function create() local x, y, z = unpack ( locations [ math.random ( #locations ) ] ) if getTeamName (getPlayerTeam(source)) == "Miners" then marker = createMarker (x, y, z, "cylinder", 2, 255, 255, 0, 255) blip = createBlipAttachedTo( marker, 0, 2, 0, 250, 0, 170 ) end end addEventHandler ("onResourceStart", root, create) addEvent ("createLoc", true) addEventHandler ("createLoc", root, create) function onHit(hitElement) if getElementType(hitElement) =="player" and getTeamName (getPlayerTeam(source)) == "Miners" then triggerEvent ("pay", getRootElement(), onHit) destroyElement (blip) destroyElement (marker) triggerEvent ("createLoc", root, onHit) end end addEventHandler ("onMarkerHit", marker, onHit) Link to comment
Baseplate Posted March 15, 2013 Share Posted March 15, 2013 if getElementType(hitElement) =="player" and getTeamName (getPlayerTeam(hitElement)) == "Workers" then I didn't use source..., source in onMarkerHit is the marker that got hit, hitElement is the element that did hit that marker. Link to comment
bradio10 Posted March 15, 2013 Author Share Posted March 15, 2013 Still is not working. If this is ment to fix it, then I have no clue what is going on. Do I have to do anything with the first getPlayerTeam at the part where it starts when the resource starts? function create() local x, y, z = unpack ( locations [ math.random ( #locations ) ] ) if getTeamName (getPlayerTeam(source)) == "Miners" then marker = createMarker (x, y, z, "cylinder", 2, 255, 255, 0, 255) blip = createBlipAttachedTo( marker, 0, 2, 0, 250, 0, 170 ) end end addEventHandler ("onResourceStart", root, create) addEvent ("createLoc", true) addEventHandler ("createLoc", root, create) Link to comment
Baseplate Posted March 15, 2013 Share Posted March 15, 2013 Try this if (getPlayerTeam(hitElement) == getTeamFromName("Miners")) then Link to comment
Renkon Posted March 15, 2013 Share Posted March 15, 2013 onResourceStart source is not a player.... just saying ^^. You cannot really make that script onResourceStart due to lack of players oto Link to comment
bradio10 Posted March 15, 2013 Author Share Posted March 15, 2013 (edited) Try this if (getPlayerTeam(hitElement) == getTeamFromName("Miners")) then Nope, not working. The markers won't appear when I get moved to it. onResourceStart source is not a player.... just saying ^^.You cannot really make that script onResourceStart due to lack of players oto Reason I put it like that is because it works fine without the team, it's just when I put the team, it doesn't work. Is that the reason why? Because if so, then how would I go about setting it out? Edited March 15, 2013 by Guest Link to comment
Baseplate Posted March 15, 2013 Share Posted March 15, 2013 I was about to ask him about the onResourceStart but forgot... onResourceStart source is not a player.... just saying ^^.You cannot really make that script onResourceStart due to lack of players oto Why are you using onResourceStart anyways? as you did add an event to it.. Link to comment
X-SHADOW Posted March 15, 2013 Share Posted March 15, 2013 (edited) . Edited March 15, 2013 by Guest Link to comment
Baseplate Posted March 15, 2013 Share Posted March 15, 2013 Don't use Money functions in client-sided +all wrong X-SHADOW. Link to comment
X-SHADOW Posted March 15, 2013 Share Posted March 15, 2013 All these won't work . why it wont ? Link to comment
iPrestege Posted March 15, 2013 Share Posted March 15, 2013 All these won't work . why it wont ? Hmm..Maybe..You will get some bad arguments . Link to comment
iPrestege Posted March 15, 2013 Share Posted March 15, 2013 Am,Back try this : locations = { {459.93146, 888.78650, -27.64281}, {507.28488, 971.90436, -24.47141}, {664.53302, 721.46564, -4.02670}, } function create() local x, y, z = unpack ( locations [ math.random ( #locations ) ] ) marker = createMarker (x, y, z, "cylinder", 2, 255, 255, 0, 255) blip = createBlipAttachedTo( marker, 0, 2, 0, 250, 0, 170 ) setElementVisibleTo ( marker, getRootElement ( ), false ) setElementVisibleTo ( blip, getRootElement ( ), false ) local players = getPlayersInTeam ( getTeamFromName ( "Miners" ) ) for k, v in ipairs ( players ) do setElementVisibleTo ( marker, v, true ) setElementVisibleTo ( blip, v, true ) end end create() function onHit(hitElement) if getElementType(hitElement) =="player" and getPlayerTeam(hitElement) and getTeamName (getPlayerTeam(hitElement)) == "Miners" then cash = math.random (500, 1000) givePlayerMoney (hitElement, cash) outputChatBox ( "You have just received $ " ..cash , hitElement, 0, 255, 0, true) fadeCamera (hitElement, false, 0.8, 0, 0, 0) setTimer ( fadeCamera, 3000, 1, hitElement, true, 1 ) if isElement(bilp) then destroyElement (blip) end removeEventHandler ("onMarkerHit", marker, onHit) destroyElement(source) setTimer( function( player ) local x, y, z = unpack ( locations [ math.random ( #locations ) ] ) marker = createMarker (x, y, z, "cylinder", 2, 255, 255, 0, 255) blip = createBlipAttachedTo( marker, 0, 2, 0, 250, 0, 170 ) setElementVisibleTo ( marker, getRootElement ( ), false ) setElementVisibleTo ( blip, getRootElement ( ), false ) local players = getPlayersInTeam ( getTeamFromName ( "Miners" ) ) for k, v in ipairs ( players ) do setElementVisibleTo ( marker, v, true ) setElementVisibleTo ( blip, v, true ) end addEventHandler ("onMarkerHit", marker, onHit) end, 1200, 1, hitElement); end end addEventHandler ("onMarkerHit", marker, onHit) Link to comment
bradio10 Posted March 15, 2013 Author Share Posted March 15, 2013 Am,Back try this : locations = { {459.93146, 888.78650, -27.64281}, {507.28488, 971.90436, -24.47141}, {664.53302, 721.46564, -4.02670}, } function create() local x, y, z = unpack ( locations [ math.random ( #locations ) ] ) marker = createMarker (x, y, z, "cylinder", 2, 255, 255, 0, 255) blip = createBlipAttachedTo( marker, 0, 2, 0, 250, 0, 170 ) setElementVisibleTo ( marker, getRootElement ( ), false ) setElementVisibleTo ( blip, getRootElement ( ), false ) local players = getPlayersInTeam ( getTeamFromName ( "Miners" ) ) for k, v in ipairs ( players ) do setElementVisibleTo ( marker, v, true ) setElementVisibleTo ( blip, v, true ) end end create() function onHit(hitElement) if getElementType(hitElement) =="player" and getPlayerTeam(hitElement) and getTeamName (getPlayerTeam(hitElement)) == "Miners" then cash = math.random (500, 1000) givePlayerMoney (hitElement, cash) outputChatBox ( "You have just received $ " ..cash , hitElement, 0, 255, 0, true) fadeCamera (hitElement, false, 0.8, 0, 0, 0) setTimer ( fadeCamera, 3000, 1, hitElement, true, 1 ) if isElement(bilp) then destroyElement (blip) end removeEventHandler ("onMarkerHit", marker, onHit) destroyElement(source) setTimer( function( player ) local x, y, z = unpack ( locations [ math.random ( #locations ) ] ) marker = createMarker (x, y, z, "cylinder", 2, 255, 255, 0, 255) blip = createBlipAttachedTo( marker, 0, 2, 0, 250, 0, 170 ) setElementVisibleTo ( marker, getRootElement ( ), false ) setElementVisibleTo ( blip, getRootElement ( ), false ) local players = getPlayersInTeam ( getTeamFromName ( "Miners" ) ) for k, v in ipairs ( players ) do setElementVisibleTo ( marker, v, true ) setElementVisibleTo ( blip, v, true ) end addEventHandler ("onMarkerHit", marker, onHit) end, 1200, 1, hitElement); end end addEventHandler ("onMarkerHit", marker, onHit) Nope, doesn't work at all Link to comment
iPrestege Posted March 15, 2013 Share Posted March 15, 2013 Are sure you are enter the Miners team or you can't see the blip and marker . Link to comment
bradio10 Posted March 15, 2013 Author Share Posted March 15, 2013 Are sure you are enter the Miners team or you can't see the blip and marker . Yes. Why? Is it working for you? Link to comment
iPrestege Posted March 15, 2013 Share Posted March 15, 2013 Yes work's with me server side! 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