jingzhi Posted February 7, 2015 Posted February 7, 2015 local marker = createMarker (1510.85327,-1673.48230,13.5, "cylinder",2.5,0,0,255) police = createTeam ("Police",0,0,255) function MarkerHit(hitElement) if getElementType(hitElement) == "player" then setElementModel(hitElement,266) setPlayerTeam (hitElement,police) outputChatBox("You have taken the Police job",hitElement,0,0,255) end end addEventHandler("onMarkerHit",marker,MarkerHit) This part is the police job script function isPlayerInTeam(player, team) assert(isElement(player) and getElementType(player) == "player", "Bad argument 1 @ isPlayerInTeam [player expected, got " .. tostring(player) .. "]") assert((not team) or type(team) == "string" or (isElement(team) and getElementType(team) == "team"), "Bad argument 2 @ isPlayerInTeam [nil/string/team expected, got " .. tostring(team) .. "]") return getPlayerTeam(player) == (type(team) == "string" and getTeamFromName(team) or (type(team) == "userdata" and team or (getPlayerTeam(player) or true))) end local marker = createMarker(1562.21423,-1607.67883,12.8,"cylinder",1.5,0,0,255) addEventHandler("onMarkerHit",marker, function(thePlayer) if getElementType(thePlayer) =="player" then if (isPedInVehicle(thePlayer)) then return end if (isPlayerInTeam(thePlayer,police)) then local x,y,z = getElementPosition(thePlayer) local veh = createVehicle (509,x,y,z) warpPedIntoVehicle (thePlayer, veh) outputChatBox("You are given a " ..getVehicleName(veh).."" ,thePlayer,0,0,255) else outputChatBox("marker unavailable") end end end) And here is the police spawner script They work, but for the spawner if you are not in "police" team, they still give you a vehicle function teamName(thePlayer) local playerteam = getPlayerTeam(thePlayer) if (playerTeam = true) then outputChatBox("Your team is "..playerTeam.."") else outputChatBox("You are not in a team") end end addCommandHandler("teamname",teamName) And please tell me, why this is not working it always say im not in a team At last, please don't go hard on me, im a noob
Tomas Posted February 7, 2015 Posted February 7, 2015 if (isPlayerInTeam(thePlayer,getTeamFromName("police")) then or if (isPlayerInTeam(thePlayer,"police")) then
jingzhi Posted February 8, 2015 Author Posted February 8, 2015 if (isPlayerInTeam(thePlayer,getTeamFromName("police")) then or if (isPlayerInTeam(thePlayer,"police")) then Thank you very much , but can you also help me to solve the other 2 problem?
Tomas Posted February 8, 2015 Posted February 8, 2015 if (isPlayerInTeam(thePlayer,getTeamFromName("police")) then or if (isPlayerInTeam(thePlayer,"police")) then Thank you very much , but can you also help me to solve the other 2 problem? What problems?
jingzhi Posted February 8, 2015 Author Posted February 8, 2015 if (isPlayerInTeam(thePlayer,getTeamFromName("police")) then or if (isPlayerInTeam(thePlayer,"police")) then Thank you very much , but can you also help me to solve the other 2 problem? What problems? The last script is also not working
TAPL Posted February 8, 2015 Posted February 8, 2015 (edited) function teamName(thePlayer) local playerTeam = getPlayerTeam(thePlayer) if (playerTeam) then outputChatBox("Your team is "..getTeamName(playerTeam)) else outputChatBox("You are not in a team") end end addCommandHandler("teamname", teamName) Edited February 8, 2015 by Guest
jingzhi Posted February 8, 2015 Author Posted February 8, 2015 function teamName(thePlayer) local playerteam = getPlayerTeam(thePlayer) if (playerTeam) then outputChatBox("Your team is "..getTeamName(playerTeam)) else outputChatBox("You are not in a team") end end addCommandHandler("teamname", teamName) It still always say, "you are not in a team" even im in a team
xeon17 Posted February 8, 2015 Posted February 8, 2015 Typo on line 3 , should be ; if (playerteam) then
jingzhi Posted February 8, 2015 Author Posted February 8, 2015 Typo on line 3 , should be ; if (playerteam) then Thanks, works now
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