Jump to content

Gui Simple Team Spawn


Try

Recommended Posts

Posted

Hi, i just back to MTA...

Help me with that code, what its wrong?

GUIEditor = { 
    button = {}, 
    window = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(671, 298, 250, 176, "Choose your team!      ", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetAlpha(GUIEditor.window[1], 1.00) 
        showCursor(true) 
        GUIEditor.button[1] = guiCreateButton(15, 34, 105, 132, "TERRORIST", false, GUIEditor.window[1]) 
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "7FFF0909") 
        GUIEditor.button[2] = guiCreateButton(130, 34, 105, 132, "POLICE", false, GUIEditor.window[1]) 
        guiSetProperty(GUIEditor.button[2], "NormalTextColour", "7F0C28FB") 
        if GUIEditor.button[1] then 
            spawnPlayer(client, 1959.55, -1714.46, 10) 
            fadeCamera(client, true) 
            setCameraTarget(client, client) 
            outputChatBox("Welcome to MyServer.", client) 
        elseif GUIEditor.button[2] then 
            spawnPlayer(client, 1959.55, -1714.46, 10) 
            fadeCamera(client, true) 
            setCameraTarget(client, client) 
            outputChatBox("Welcome to MyServer.", client) 
        end 
    end 
end 
) 

Posted

Try to learn from it.

Client Side:

GUIEditor = { 
    button = {}, 
    window = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
function() 
    GUIEditor.window[1] = guiCreateWindow(671, 298, 250, 176, "Choose your team!      ", false) 
    guiWindowSetSizable(GUIEditor.window[1], false) 
    guiSetAlpha(GUIEditor.window[1], 1.00) 
    showCursor(true) 
    GUIEditor.button[1] = guiCreateButton(15, 34, 105, 132, "TERRORIST", false, GUIEditor.window[1]) 
    guiSetProperty(GUIEditor.button[1], "NormalTextColour", "7FFF0909") 
    GUIEditor.button[2] = guiCreateButton(130, 34, 105, 132, "POLICE", false, GUIEditor.window[1]) 
    guiSetProperty(GUIEditor.button[2], "NormalTextColour", "7F0C28FB") 
end) 
  
addEventHandler("onClientGUIClick", root, 
function() 
    if source == GUIEditor.button[1] then 
        showCursor(false) 
        triggerServerEvent("onTeamSelect", localPlayer, "TERRORIST") 
    elseif source == GUIEditor.button[2] then 
        showCursor(false) 
        triggerServerEvent("onTeamSelect", localPlayer, "POLICE") 
    end 
end) 

Server Side:

TerroristTeam = createTeam("TERRORIST", 255, 0, 0) 
PoliceTeam = createTeam("POLICE", 0, 0, 255) 
  
addEvent("onTeamSelect", true) 
addEventHandler("onTeamSelect", root, 
function(team) 
    if team == "TERRORIST" then 
        spawnPlayer(client, 1959.55, -1714.46, 10, 0, 0, 0, 0, TerroristTeam) 
    elseif team == "POLICE" then 
        spawnPlayer(client, 1959.55, -1714.46, 10, 0, 0, 0, 0, PoliceTeam) 
    end 
    fadeCamera(client, true) 
    setCameraTarget(client) 
    outputChatBox("Welcome to MyServer.", client) 
end) 

Posted

Sever-Side:

I just add on player wasted but it dont works... added the

setElementData and getElementData

TerroristTeam = createTeam("TERRORIST", 255, 0, 0) 
PoliceTeam = createTeam("POLICE", 0, 0, 255) 
  
addEvent("onTeamSelect", true) 
addEventHandler("onTeamSelect", root, 
function(team) 
    local sPlayerNickname = getPlayerName ( source ) 
    if team == "TERRORIST" then 
        spawnPlayer(client, 1959.55, -1714.46, 10, 0, 0, 0, 0, TerroristTeam) 
        setElementData ( source, "terrorist", sPlayerNickname) 
    elseif team == "POLICE" then 
        spawnPlayer(source, 1959.55, -1714.46, 10, 0, 0, 0, 0, PoliceTeam) 
        setElementData ( source, "police", sPlayerNickname) 
    end 
    fadeCamera(source, true) 
    setCameraTarget(source) 
    outputChatBox("Welcome to MyServer.", client) 
end) 
  
addEventHandler("onPlayerWasted", root, 
function(source) 
    if getElementData ( client, "terrorist") then 
        spawnPlayer(client, 1959.55, -1714.46, 10, 0, 0, 0, 0, TerroristTeam) 
    elseif getElementData ( source, "police") then 
        spawnPlayer(source, 1959.55, -1714.46, 10, 0, 0, 0, 0, PoliceTeam) 
    end 
    fadeCamera(source, true) 
    setCameraTarget(source) 
    outputChatBox("#00ff00You have Respawned!", source) 
end) 

Posted
TerroristTeam = createTeam("TERRORIST", 255, 0, 0) 
PoliceTeam = createTeam("POLICE", 0, 0, 255) 
  
addEvent("onTeamSelect", true) 
addEventHandler("onTeamSelect", root, 
function(team) 
    local sPlayerNickname = getPlayerName ( source ) 
    if team == "TERRORIST" then 
        spawnPlayer(source, 1959.55, -1714.46, 10, 0, 0, 0, 0, TerroristTeam) 
        outputChatBox(#ff0000".~ You selected TERRORIST ~.", source) 
    elseif team == "POLICE" then 
        outputChatBox(#0000ff".~ You selected POLICE ~.", source)     
        spawnPlayer(source, 1959.55, -1714.46, 10, 0, 0, 0, 0, PoliceTeam) 
    end 
    fadeCamera(source, true) 
    setCameraTarget(source) 
end) 
  
addEventHandler("onPlayerWasted", root, 
function(team) 
    local hueteam = getPlayerTeam (team) 
    if hueteam == TerroristTeam then 
        spawnPlayer(source, 1959.55, -1714.46, 10, 0, 0, 0, 0, TerroristTeam) 
    elseif hueteam == PoliceTeam then 
        spawnPlayer(source, 1959.55, -1714.46, 10, 0, 0, 0, 0, PoliceTeam) 
    end 
    fadeCamera(source, true) 
    setCameraTarget(source) 
    outputChatBox("#00ff00.~ You have been respawned! ~.", source) 
end) 

Stills not working

Posted

Line 10 and 12 the color code should go after " not before (same as line 29).

Line 21 use source not team and remove team from line 20 (empty).

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