Jump to content

I need help!


KraZ

Recommended Posts

Okay so im making a TDM server based on objective based games like bank robbery, defend the vault for 5 mins to win, etc...

So i made this script but for some reason it doesn't spawn a player and stuff, i have no debug errors either, Basically the timer and everything works but once it starts the activity it shows a gui which is below, but then I click on the button to pick a team i send that to the serverside and it doesn't spawn the player or set the player team, any help?

GUI

  
  
addEvent("showTeamWindow", true) 
addEventHandler("showTeamWindow", getRootElement(),  
function() 
  
    guiSetInputEnabled(true) 
    showCursor(true) 
     
    teamSelectionWindow = guiCreateWindow(489, 284, 388, 109, "Select a team:", false) 
    guiWindowSetSizable(teamSelectionWindow, false) 
  
    criminalButton = guiCreateButton(14, 31, 171, 54, "Criminals", false, teamSelectionWindow) 
    addEventHandler("onClientGUIClick", criminalButton, selectCrim, false) 
    guiSetFont(criminalButton, "default-bold-small") 
    guiSetProperty(criminalButton, "NormalTextColour", "FFAAAAAA") 
    copButton = guiCreateButton(195, 31, 171, 54, "Law Enforcement", false, teamSelectionWindow) 
    addEventHandler("onClientGUIClick", copButton, selectCop, false) 
    guiSetFont(copButton, "default-bold-small") 
    guiSetProperty(copButton, "NormalTextColour", "FFAAAAAA")     
end 
) 
  
function selectCop(button, state) 
    if button == "left" and state == "up" then 
        triggerServerEvent("selectCopTeam", getLocalPlayer()) 
    end 
end 
  
function selectCrim(button, state) 
    if button == "left" and state == "up" then 
        triggerServerEvent("selectCrimTeam", getLocalPlayer()) 
    end 
end 

SERVERSIDE:

addEventHandler("onResourceStart", resourceRoot,  
function() 
    criminalTeam = createTeam ( "Criminal", 255, 0, 0 ) 
    policeTeam = createTeam ( "Police", 0, 0, 255 ) 
    defaultTeam = createTeam ( "Default", 255, 255, 255 )   
end 
) 
  
addEvent("selectCopTeam", true) 
addEventHandler("selectCopTeam", getRootElement(),  
function() 
    setPlayerTeam ( source, policeTeam ) 
    spawnPlayer(source, 1344, 3257, 52, 0, 285) 
end 
) 
  
addEvent("selectCrimTeam", true) 
addEventHandler("selectCrimTeam", getRootElement(),  
function() 
    setPlayerTeam ( source, criminalTeam ) 
    spawnPlayer(source, 1389, 3292, 4, 0, 104) 
end 
) 
  
function player_Wasted( ammo, attacker, weapon, bodypart ) 
    if ( attacker ) then 
        local tempString 
        if ( getElementType ( attacker ) == "player" ) then 
            givePlayerMoney ( attacker, 100 ) 
        end 
        local teamCriminal = getTeamFromName ( "Criminal" ) 
        local teamPolice = getTeamFromName ( "Police" ) 
        local playerTeam = getPlayerTeam ( source )           
        if ( playerTeam == teamCriminal) then    
            spawnPlayer(source, 1389, 3292, 4, 0, 104) 
        elseif (playerTeam == teamPolice) then 
            spawnPlayer(source, 1344, 3257, 52, 0, 285) 
        end 
    end 
     
end 
addEventHandler ( "onPlayerWasted", getRootElement(), player_Wasted ) 
  
  
function activityStart() 
    triggerClientEvent("showTeamWindow", getRootElement()) 
    triggerClientEvent("bankRob", getRootElement()) 
end 
addEvent("startActivity", true) 
addEventHandler("startActivity", getRootElement(), activityStart) 
  
  
function activityStop() 
    for id, allPlayers in ipairs(getElementsByType("player")) do 
    local teamDefault = getTeamFromName ( "Default" ) 
    setPlayerTeam ( allPlayers, teamDefault ) 
    killPed( allPlayers ) 
    end 
end 
addEvent("stopActivity", true) 
addEventHandler("stopActivity", getRootElement(), activityStop) 

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