Gtagasje Posted December 17, 2011 Share Posted December 17, 2011 Hi, I wanna create a one of the given markers if you enter a vehicle, and if you are on the team "Criminal". I tried this script [i made it server side]: local criminal = createTeam("Criminal", 255, 0, 0) function createAmarker () if getPlayerTeam(getTeamFromName(criminal)) then theMarkers = { createMarker (0, 0, 20), createMarker (1, 0, 20), createMarker (2, 0, 20), createMarker (3, 0, 20) } markersTable[math.random(#theMarkers)] end end addEventHandler("onVehicleEnter", getRootElement(), createAmarker) but it shows this error: "SCRIPT ERROR: :line 11: '=' expected near end." I don't know how to fix this, I tried a lot of things, but I wasn't able to fix this. Once again in short, I wan't the script to create one of the markers in the script, if the player (on criminal team) enters a vehicle. But it shows that error, which i'm not able to fix. Regards, Gtagasje Link to comment
Al3grab Posted December 17, 2011 Share Posted December 17, 2011 well, it can be done like this local criminal = createTeam("Criminal", 255, 0, 0) function randomMarker() randomNum = math.random(1,4) if randomNum == 1 then createMarker (0, 0, 20) elseif randomNum == 2 then createMarker (1, 0, 20) elseif randomNum == 3 then createMarker (2, 0, 20) elseif randomNum == 4 then createMarker (3, 0, 20) end end function createAmarker (plr) if getPlayerTeam(plr) == getTeamFromName("Criminal") then randomMarker() end end addEventHandler("onVehicleEnter", getRootElement(), createAmarker) Link to comment
drk Posted December 17, 2011 Share Posted December 17, 2011 Try this: local criminal = createTeam("Criminal", 255, 0, 0) function createAmarker () if getPlayerTeam(getTeamFromName(criminal)) then local theMarkers = { createMarker (0, 0, 20), createMarker (1, 0, 20), createMarker (2, 0, 20), createMarker (3, 0, 20) } markersTable[math.random(#theMarkers)] end end addEventHandler("onVehicleEnter", getRootElement(), createAmarker) You need 'local' before theMarkers. Link to comment
Castillo Posted December 17, 2011 Share Posted December 17, 2011 local criminal = createTeam("Criminal", 255, 0, 0) local positions = { {0, 0, 20}, {1, 0, 20}, {2, 0, 20}, {3, 0, 20}, } function createAmarker (thePlayer) if ( getPlayerTeam(thePlayer) and getPlayerTeam(thePlayer) == criminal ) then local x, y,z = unpack(positions[math.random(#positions)]) createMarker(x, y, z) end end addEventHandler("onVehicleEnter", getRootElement(), createAmarker) Link to comment
drk Posted December 17, 2011 Share Posted December 17, 2011 Solidsnake14, was not necessary to you reply. I have already answered and Gtagasje had achieved ... Link to comment
Castillo Posted December 17, 2011 Share Posted December 17, 2011 We can say... two options is better than one? Link to comment
drk Posted December 17, 2011 Share Posted December 17, 2011 Why Gtagasje need two options if only one is needed ? Ok, no problem, I don't want to "fight" in the forum ... Link to comment
Castillo Posted December 17, 2011 Share Posted December 17, 2011 Who knows? maybe someone ELSE has the same problem and want's to do it in a different way, nobody know's. Link to comment
AGENT_STEELMEAT Posted December 17, 2011 Share Posted December 17, 2011 Or we could say that your solution sucks Shick. Link to comment
drk Posted December 17, 2011 Share Posted December 17, 2011 LOL, I will not reply to noob's. Link to comment
AGENT_STEELMEAT Posted December 17, 2011 Share Posted December 17, 2011 You just did. Link to comment
Xeno Posted December 17, 2011 Share Posted December 17, 2011 Lol. I think it was necessary for Castillo to reply because im about to use his script he posted >_> Link to comment
Al3grab Posted December 19, 2011 Share Posted December 19, 2011 @-NxZ-Shick Solid's Solution was better than mine Link to comment
Spice Posted July 13, 2015 Share Posted July 13, 2015 Who knows? maybe someone ELSE has the same problem and want's to do it in a different way, nobody know's. Thanks man <3 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