Jump to content

Please help with my team spawner scripts...


jingzhi

Recommended Posts

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 :mrgreen:

Link to comment
  
        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

Link to comment
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 by Guest
Link to comment
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 :(

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...