Jump to content

[HELP] getPlayerTeam


Recommended Posts

function playerTeamC () 
local playerTeam = getPlayerTeam ( source ) 
outputChatBox ( playerTeam, source ) 
end 
addEventHandler ( "onPlayerSpawn", source, playerTeamC) 

This should work shouldn't it? I get this message in the console "WARNING: [GRNFS]\gr_cteam\server.lua:2: Bad 'player' pointer @ 'getPlayerTeam'(1)

Link to comment

can you please explain why this doesnt work?

  
function damage() 
playerTeam = getTeamName ( getPlayerTeam ( source ) ) 
if playerTeam == ("Police Officers") then 
        outputChatBox ("COP",source) 
    else 
    outputChatBox ("Not A COP",source) 
    end if 
end 
addEventHandler( "onVehicleDamage", root, damage) 
  

Link to comment
Use the function: getVehicleController to get the vehicle driver.

i suck at this, cant get anything right :( would you mind helping me out with the previous code you gave me?

  
--if you still remember, it tells the zoneowner if there is a player in it, now i want to change it so it only tells a person in the team "Street Racers" that there is a player in the "Police Officers" Team nearby when a player from the "Police Officers" team steps in the collision. 
local playerZones = { } 
  
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        for index, player in ipairs ( getElementsByType ( "player" ) ) do 
            playerZones [ player ] = createColTube ( 0, 0, 0, 10.0, 100.0 ) 
            attachElements ( playerZones [ player ], player, 0, 0, 0 ) 
            setElementData ( playerZones [ player ], "zoneOwner", player ) 
            addEventHandler ( "onColShapeHit", playerZones [ player ], zoneEnter ) 
        end 
    end 
) 
  
function createZone ( ) 
    playerZones [ source ] = createColTube ( 0, 0, 0, 10.0, 100.0 ) 
    attachElements ( playerZones [ source ], source, 0, 0, 0 ) 
    setElementData ( playerZones [ source ], "zoneOwner", source ) 
    addEventHandler ( "onColShapeHit", playerZones [ source ], zoneEnter ) 
    playerTeam = getTeamName ( getPlayerTeam ( source ) ) 
    outputChatBox ( playerTeam, source ) 
end 
addEventHandler ( "onPlayerJoin", root, createZone ) 
addEventHandler ( "onPlayerSpawn", root, createZone ) 
  
function destroyZone ( ) 
    if ( isElement ( playerZones [ source ] ) ) then 
        destroyElement ( playerZones [ source ] ) 
    end 
end 
addEventHandler ( "onPlayerQuit", root, destroyZone ) 
  
function zoneEnter ( ) 
    if ( zoneOwner ) == false  then 
        outputChatBox ("There is a player in your zone!",zoneOwner) 
    end 
end 
  
function giveMoney ( ) 
    for index, player in ipairs ( getElementsWithinColShape ( playerZone, "player" ) ) do 
        givePlayerMoney ( player, 5000 ) 
        outputChatBox ("Congratulations, you have been rewarded $5000 for capturing " .. root ,player) 
        destroyZone() 
    end 
end 
addEventHandler ( "onPlayerWasted", root, giveMoney ) 
  

Link to comment
--if you still remember, it tells the zoneowner if there is a player in it, now i want to change it so it only tells a person in the team "Street Racers" that there is a player in the "Police Officers" Team nearby when a player from the "Police Officers" team steps in the collision. 
local playerZones = { } 
  
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        for index, player in ipairs ( getElementsByType ( "player" ) ) do 
            playerZones [ player ] = createColTube ( 0, 0, 0, 10.0, 100.0 ) 
            attachElements ( playerZones [ player ], player, 0, 0, 0 ) 
            setElementData ( playerZones [ player ], "zoneOwner", player ) 
            addEventHandler ( "onColShapeHit", playerZones [ player ], zoneEnter ) 
        end 
    end 
) 
  
function createZone ( ) 
    playerZones [ source ] = createColTube ( 0, 0, 0, 10.0, 100.0 ) 
    attachElements ( playerZones [ source ], source, 0, 0, 0 ) 
    setElementData ( playerZones [ source ], "zoneOwner", source ) 
    addEventHandler ( "onColShapeHit", playerZones [ source ], zoneEnter ) 
    playerTeam = getTeamName ( getPlayerTeam ( source ) ) 
    outputChatBox ( playerTeam, source ) 
end 
addEventHandler ( "onPlayerJoin", root, createZone ) 
addEventHandler ( "onPlayerSpawn", root, createZone ) 
  
function destroyZone ( ) 
    if ( isElement ( playerZones [ source ] ) ) then 
        destroyElement ( playerZones [ source ] ) 
    end 
end 
addEventHandler ( "onPlayerQuit", root, destroyZone ) 
  
function zoneEnter ( hitElement ) 
    local zoneOwner = getElementData ( source, "zoneOwner" ) 
    if ( zoneOwner ~= hitElement )  then 
        outputChatBox ( "There is a player in your zone!", zoneOwner ) 
    end 
end 
  
function giveMoney ( ) 
    for index, player in ipairs ( getElementsWithinColShape ( playerZone, "player" ) ) do 
        givePlayerMoney ( player, 5000 ) 
        outputChatBox ("Congratulations, you have been rewarded $5000 for capturing " .. root ,player) 
        destroyZone() 
    end 
end 
addEventHandler ( "onPlayerWasted", root, giveMoney ) 

Link to comment
  • 4 weeks later...

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...