Sande Posted May 1, 2014 Share Posted May 1, 2014 Hello, i have problem with my script. The problem is after the check occupation part, if there is criminal(thePlayer), it doesn´t run the function. This script should work like this: If player occupation is criminal, then this script sets him to criminal team. function jonne() local players = getElementsByType ( "player" ) for theKey,thePlayer in ipairs(players) do if ( thePlayer ) then local occ = getElementData(thePlayer, "Occupation") if occ == false then return end if getElementData(thePlayer, "Occupation") == "Criminal" then criminal(thePlayer) outputChatBox("Criminal-found") return end elseif getElementData(thePlayer, "Occupation") == "Police" then police(thePlayer) elseif getElementData(thePlayer, "Occupation") == "Trucker" then trucker(thePlayer) elseif getElementData(thePlayer, "Occupation") == "Medic" then medic(thePlayer) elseif getElementData(thePlayer, "Occupation") == "Freeroam" then freeroam(thePlayer) elseif getElementData(thePlayer, "Occupation") == "Staff" then staff(thePlayer) elseif getElementData(thePlayer, "Occupation") == "Unemployed" then unemployed(thePlayer) elseif getElementData(thePlayer, "Occupation") == "FBI Agent" then fbi(thePlayer) elseif getElementData(thePlayer, "Occupation") == "Army" then army(thePlayer) elseif getElementData(thePlayer, "Occupation") == "SWAT Agent" then swat(thePlayer) else setElementData(thePlayer, "Occupation", "Unemployed") setPlayerTeam(thePlayer, getTeamFromName("Unemployed")) end end end function timer1() setTimer(jonne, 500, 0) end function army(thePlayer) --local team4 = getTeamFromName("Army") setPlayerTeam(thePlayer, getTeamFromName("Army")) end function fbi(thePlayer) --local team5 = getTeamFromName("FBI") setPlayerTeam(thePlayer, getTeamFromName("FBI")) end function swat(thePlayer) --local team6 = getTeamFromName("SWAT") setPlayerTeam(thePlayer, getTeamFromName("SWAT")) end function staff(thePlayer) --local team7 = getTeamFromName("Staff") setPlayerTeam(thePlayer, getTeamFromName("Staff")) end function freeroam(thePlayer) --local team8 = getTeamFromName("Freeroam") setPlayerTeam(thePlayer, getTeamFromName("Freeroam")) end function unemployed(thePlayer) --local team9 = getTeamFromName("Unemployed") setPlayerTeam(thePlayer, getTeamFromName("Unemployed")) end --[[function criminal(thePlayer) --local team = getTeamFromName("Criminal") outputChatBox("Criminal-set") setPlayerTeam(thePlayer, getTeamFromName("Criminal")) end--]] function police(thePlayer) --local team1 = getTeamFromName("Police") setPlayerTeam(thePlayer, getTeamFromName("Police")) end function trucker(thePlayer) --local team2 = getTeamFromName("Civilians") setPlayerTeam(thePlayer, getTeamFromName("Civilians")) end function medic(thePlayer) --local team3 = getTeamFromName("Emergency") setPlayerTeam(thePlayer, getTeamFromName("Emergency")) end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), jonne ) Link to comment
justn Posted May 1, 2014 Share Posted May 1, 2014 I would use onPlayerLogin instead.. try this.. addEventHandler("onPlayerLogin",getRootElement(), function() if getElementData(source,"Occupation") == "Criminal" then setPlayerTeam(source, getTeamFromName("Criminal")) elseif getElementData(source,"Occupation") == "Police" then setPlayerTeam(source, getTeamFromName("Police")) elseif getElementData(source, "Occupation") == "Trucker" then setPlayerTeam(source, getTeamFromName("Civilians")) elseif getElementData(source, "Occupation") == "Medic" then setPlayerTeam(source, getTeamFromName("Emergency")) elseif getElementData(source, "Occupation") == "Freeroam" then setPlayerTeam(source, getTeamFromName("Freeroam")) elseif getElementData(source, "Occupation") == "Staff" then setPlayerTeam(source, getTeamFromName("Staff")) elseif getElementData(source, "Occupation") == "Unemployed" then setPlayerTeam(source, getTeamFromName("Unemployed")) elseif getElementData(source, "Occupation") == "FBI Agent" then setPlayerTeam(source, getTeamFromName("FBI")) elseif getElementData(source, "Occupation") == "Army" then setPlayerTeam(source, getTeamFromName("Army")) elseif getElementData(source, "Occupation") == "SWAT Agent" then setPlayerTeam(source, getTeamFromName("SWAT")) else setElementData(source, "Occupation", "Unemployed") setPlayerTeam(source, getTeamFromName("Unemployed")) end end ) 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