Jump to content

Team selector


-.Paradox.-

Recommended Posts

Hello, i made this code, it suppose to show for the players a team selection and they have to select btw 2 teams, only when they login, and set camera matrix on vinewood sign, This is my code thanks for help :P

GUIEditor = { 
    button = {}, 
} 
  
function setCamera() 
  dxDrawText("Resistance", 764, 141, 1004, 191, tocolor(255, 0, 0, 255), 1.30, "bankgothic", "center", "top", false, false, true, false, false) 
  dxDrawImage(845, 191, 68, 63, ":Class/class/Classicon_warrior.png", 333, 0, 0, tocolor(255, 255, 255, 255), true) 
  dxDrawText("F.B.I", 466, 141, 706, 190, tocolor(0, 0, 255, 255), 1.30, "bankgothic", "left", "top", false, false, true, false, false) 
  dxDrawImage(466, 191, 67, 64, ":Class/class/Classicon_psyron.png", 33, 0, 0, tocolor(255, 255, 255, 255), true) 
  dxDrawText("Click on the team you want to join!", 533, 22, 847, 141, tocolor(0, 255, 0, 255), 1.00, "bankgothic", "left", "top", false, true, true, false, false) 
        GUIEditor.button[1] = guiCreateButton(847, 254, 157, 46, ">>", false) 
  
        guiSetFont(GUIEditor.button[1], "default-bold-small") 
  
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFFF0000") 
  
  
  
        GUIEditor.button[2] = guiCreateButton(376, 254, 157, 46, "<<", false) 
  
        guiSetFont(GUIEditor.button[2], "default-bold-small") 
  
        guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FF0000FF")    
     fadeCamera(source, true, 5) 
     setCameraMatrix(source, 1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316) 
end 
addEventHandler("onClientRender", getRootElement(), setCamera) 
  
function imageC() 
    setPlayerTeam ( source, Resistance ) 
end 
addEventHandler ( "onClientGUIClick", GUIEditor.button[1], imageC, false ) 
  
function imageTest() 
    setPlayerTeam ( source, F.B.I ) 
end 
addEventHandler ( "onClientGUIClick", GUIEditor.button[2], imageTest, false ) 

Link to comment

Client Side:

GUIEditor = { 
    button = {}, 
} 
  
GUIEditor.button[1] = guiCreateButton(847, 254, 157, 46, ">>", false) 
guiSetFont(GUIEditor.button[1], "default-bold-small") 
guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFFF0000") 
GUIEditor.button[2] = guiCreateButton(376, 254, 157, 46, "<<", false) 
guiSetFont(GUIEditor.button[2], "default-bold-small") 
guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FF0000FF")   
fadeCamera(true, 5) 
setCameraMatrix(1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316) 
  
function setCamera() 
  dxDrawText("Resistance", 764, 141, 1004, 191, tocolor(255, 0, 0, 255), 1.30, "bankgothic", "center", "top", false, false, true, false, false) 
  dxDrawImage(845, 191, 68, 63, ":Class/class/Classicon_warrior.png", 333, 0, 0, tocolor(255, 255, 255, 255), true) 
  dxDrawText("F.B.I", 466, 141, 706, 190, tocolor(0, 0, 255, 255), 1.30, "bankgothic", "left", "top", false, false, true, false, false) 
  dxDrawImage(466, 191, 67, 64, ":Class/class/Classicon_psyron.png", 33, 0, 0, tocolor(255, 255, 255, 255), true) 
  dxDrawText("Click on the team you want to join!", 533, 22, 847, 141, tocolor(0, 255, 0, 255), 1.00, "bankgothic", "left", "top", false, true, true, false, false) 
end 
addEventHandler("onClientRender", getRootElement(), setCamera) 
  
function imageC() 
    triggerServerEvent("setTeam", localPlayer, getTeamFromName("Resistance")) 
end 
addEventHandler("onClientGUIClick", GUIEditor.button[1], imageC, false) 
  
function imageTest() 
    triggerServerEvent("setTeam", localPlayer, getTeamFromName("F.B.I")) 
end 
addEventHandler("onClientGUIClick", GUIEditor.button[2], imageTest, false) 

Server Side:

addEvent("setTeam", true) 
addEventHandler("setTeam", root, 
function(team) 
    if team then 
        setPlayerTeam(source, team) 
    end 
end) 

Link to comment

When i click on the buttons it dont set the team i want to join, and i want to spawn the player after selecting the team, and destroy the image and buttons and other stuffs.

addEventHandler("onPlayerJoin", getRootElement, 
function () 
createTeam ("F.B.I", 0, 255, 0) 
createTeam ("Resistance", 255, 0, 0) 
end 
) 
GUIEditor = { 
    button = {}, 
} 
  
GUIEditor.button[1] = guiCreateButton(847, 254, 157, 46, ">>", false) 
guiSetFont(GUIEditor.button[1], "default-bold-small") 
guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFFF0000") 
GUIEditor.button[2] = guiCreateButton(376, 254, 157, 46, "<<", false) 
guiSetFont(GUIEditor.button[2], "default-bold-small") 
guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FF0000FF") 
showCursor(true)   
fadeCamera(true, 5) 
setCameraMatrix(1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316) 
  
function setCamera() 
  dxDrawText("Resistance", 764, 141, 1004, 191, tocolor(255, 0, 0, 255), 1.30, "bankgothic", "center", "top", false, false, true, false, false) 
  dxDrawImage(845, 191, 68, 63, ":Class/class/Classicon_warrior.png", 333, 0, 0, tocolor(255, 255, 255, 255), true) 
  dxDrawText("F.B.I", 466, 141, 706, 190, tocolor(0, 0, 255, 255), 1.30, "bankgothic", "left", "top", false, false, true, false, false) 
  dxDrawImage(466, 191, 67, 64, ":Class/class/Classicon_psyron.png", 33, 0, 0, tocolor(255, 255, 255, 255), true) 
  dxDrawText("Click on the team you want to join!", 533, 22, 847, 141, tocolor(0, 255, 0, 255), 1.00, "bankgothic", "left", "top", false, true, true, false, false) 
end 
addEventHandler("onPlayerLogin", getRootElement(), setCamera) 
  
function imageC() 
    triggerServerEvent("setTeam", localPlayer, getTeamFromName("Resistance")) 
end 
addEventHandler("onClientGUIClick", GUIEditor.button[1], imageC, false) 
  
function imageTest() 
    triggerServerEvent("setTeam", localPlayer, getTeamFromName("F.B.I")) 
end 
addEventHandler("onClientGUIClick", GUIEditor.button[2], imageTest, false) 

Link to comment

Server Side:

createTeam ("F.B.I", 0, 255, 0) 
createTeam ("Resistance", 255, 0, 0) 
  
addEvent("setTeam", true) 
addEventHandler("setTeam", root, 
function(team) 
    if team then 
        spawnPlayer(source, x, y, z, 0, skin, 0, 0, team) 
        -- replace x, y, z with the position and skin with the id. 
        setCameraTarget(source) 
        triggerClientEvent(source, "onSelectTeam", source) 
    end 
end) 

Client Side:

GUIEditor = { 
    button = {}, 
} 
  
GUIEditor.button[1] = guiCreateButton(847, 254, 157, 46, ">>", false) 
guiSetFont(GUIEditor.button[1], "default-bold-small") 
guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFFF0000") 
GUIEditor.button[2] = guiCreateButton(376, 254, 157, 46, "<<", false) 
guiSetFont(GUIEditor.button[2], "default-bold-small") 
guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FF0000FF")   
fadeCamera(true, 5) 
showCursor(true) 
setCameraMatrix(1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316) 
  
function setCamera() 
  dxDrawText("Resistance", 764, 141, 1004, 191, tocolor(255, 0, 0, 255), 1.30, "bankgothic", "center", "top", false, false, true, false, false) 
  dxDrawImage(845, 191, 68, 63, ":Class/class/Classicon_warrior.png", 333, 0, 0, tocolor(255, 255, 255, 255), true) 
  dxDrawText("F.B.I", 466, 141, 706, 190, tocolor(0, 0, 255, 255), 1.30, "bankgothic", "left", "top", false, false, true, false, false) 
  dxDrawImage(466, 191, 67, 64, ":Class/class/Classicon_psyron.png", 33, 0, 0, tocolor(255, 255, 255, 255), true) 
  dxDrawText("Click on the team you want to join!", 533, 22, 847, 141, tocolor(0, 255, 0, 255), 1.00, "bankgothic", "left", "top", false, true, true, false, false) 
end 
addEventHandler("onClientRender", getRootElement(), setCamera) 
  
function imageC() 
    triggerServerEvent("setTeam", localPlayer, getTeamFromName("Resistance")) 
end 
addEventHandler("onClientGUIClick", GUIEditor.button[1], imageC, false) 
  
function imageTest() 
    triggerServerEvent("setTeam", localPlayer, getTeamFromName("F.B.I")) 
end 
addEventHandler("onClientGUIClick", GUIEditor.button[2], imageTest, false) 
  
addEvent("onSelectTeam", true) 
addEventHandler("onSelectTeam", root, 
function() 
    removeEventHandler("onClientRender", getRootElement(), setCamera) 
    destroyElement(GUIEditor.button[1]) 
    destroyElement(GUIEditor.button[2]) 
    showCursor(false) 
end) 

Link to comment

See if this work. :mrgreen:

Server Side:

createTeam ("F.B.I", 0, 255, 0) 
createTeam ("Resistance", 255, 0, 0) 
  
addEvent("setTeam", true) 
addEventHandler("setTeam", root, 
function(team) 
    if team then 
        spawnPlayer(source, x, y, z, 0, 0, 0, 0, team) 
        setCameraTarget(source) 
        triggerClientEvent(source, "onSelectTeam", source) 
    end 
end) 
  
addEventHandler("onPlayerLogin", root, 
function() 
    triggerClientEvent(source, "onLogin", source) 
end) 

Client Side:

addEvent("onLogin", true) 
addEventHandler("onLogin", root, 
function() 
  
GUIEditor = { 
    button = {}, 
} 
  
GUIEditor.button[1] = guiCreateButton(847, 254, 157, 46, ">>", false) 
guiSetFont(GUIEditor.button[1], "default-bold-small") 
guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFFF0000") 
GUIEditor.button[2] = guiCreateButton(376, 254, 157, 46, "<<", false) 
guiSetFont(GUIEditor.button[2], "default-bold-small") 
guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FF0000FF")   
fadeCamera(true, 5) 
showCursor(true) 
setCameraMatrix(1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316) 
  
function setCamera() 
  dxDrawText("Resistance", 764, 141, 1004, 191, tocolor(255, 0, 0, 255), 1.30, "bankgothic", "center", "top", false, false, true, false, false) 
  dxDrawImage(845, 191, 68, 63, ":Class/class/Classicon_warrior.png", 333, 0, 0, tocolor(255, 255, 255, 255), true) 
  dxDrawText("F.B.I", 466, 141, 706, 190, tocolor(0, 0, 255, 255), 1.30, "bankgothic", "left", "top", false, false, true, false, false) 
  dxDrawImage(466, 191, 67, 64, ":Class/class/Classicon_psyron.png", 33, 0, 0, tocolor(255, 255, 255, 255), true) 
  dxDrawText("Click on the team you want to join!", 533, 22, 847, 141, tocolor(0, 255, 0, 255), 1.00, "bankgothic", "left", "top", false, true, true, false, false) 
end 
addEventHandler("onClientRender", getRootElement(), setCamera) 
  
function imageC() 
    triggerServerEvent("setTeam", localPlayer, getTeamFromName("Resistance")) 
end 
addEventHandler("onClientGUIClick", GUIEditor.button[1], imageC, false) 
  
function imageTest() 
    triggerServerEvent("setTeam", localPlayer, getTeamFromName("F.B.I")) 
end 
addEventHandler("onClientGUIClick", GUIEditor.button[2], imageTest, false) 
  
addEvent("onSelectTeam", true) 
addEventHandler("onSelectTeam", root, 
function() 
    removeEventHandler("onClientRender", getRootElement(), setCamera) 
    destroyElement(GUIEditor.button[1]) 
    destroyElement(GUIEditor.button[2]) 
    showCursor(false) 
end) 
  
end) 

Link to comment

Server triggered clientside event onLogin, but event is not added clientside

Edit:

Here is my login panel, if its possible, i want to dont spawn player when login until he select team, and once team is selected then he can play. thanks :P

wdwLogin_Pannel = {} 
tabPannel_Main = {}
tab_Login = {}
 
blackLoginScreen = true
blackScreenTime = 5
GuestEnable = true
 
 
 
function open_log_reg_pannel()
    if not(isElement(wdwLogin_Pannel)) then
   
    if blackLoginScreen == true then
        fadeCamera(false,0,0,0,0)
   
        end 
    local sWidth,sHeight = guiGetScreenSize()
    local Width,Height = 473,284
    local X = (sWidth/2) - (Width/2)   
    local Y = (sHeight/2) - (Height/2) 
    wdwLogin_Pannel = guiCreateWindow(X,Y,Width,Height,"Resident Evil Login",false)
   
   
    guiWindowSetSizable(wdwLogin_Pannel,false)
   
   
    tabPannel_Main = guiCreateTabPanel(9,23,455,251,false,wdwLogin_Pannel)
   
   
    tab_Login = guiCreateTab("Login",tabPannel_Main)
   
   
    lbl_Login = guiCreateLabel(103,72,42,19,"Login:",false,tab_Login)
   
    guiLabelSetVerticalAlign(lbl_Login,"center")
   
    guiLabelSetHorizontalAlign(lbl_Login,"right",false)
   
    guiSetFont(lbl_Login,"default-bold-small")
   
   
    edit_Login = guiCreateEdit(156,72,169,23,"",false,tab_Login)   
    edit_password = guiCreateEdit(156,106,169,23,"",false,tab_Login)   
    guiEditSetMaxLength ( edit_Login,22)
   
    guiEditSetMaxLength ( edit_password,22)
   
    guiEditSetMasked ( edit_password, true )
 
   
   
    lbl_Password = guiCreateLabel(48,106,96,19,"Password:",false,tab_Login)
   
    guiLabelSetVerticalAlign(lbl_Password,"center")
   
    guiLabelSetHorizontalAlign(lbl_Password,"right",false)
   
    guiSetFont(lbl_Password,"default-bold-small")
   
   
    lbl_top_info = guiCreateLabel(0,0,473,35,"Please enter you're username/password ! Have fun",false,tab_Login)
    guiLabelSetColor(lbl_top_info,255,255,255)
   
    guiLabelSetVerticalAlign(lbl_top_info,"center")
   
    guiLabelSetHorizontalAlign(lbl_top_info,"center",false)
   
   
    lbl_about_legth = guiCreateLabel(142,42,184,18,"Max Length: 22 symbols",false,tab_Login)
   
    guiLabelSetColor(lbl_about_legth,255,255,255)
   
    guiLabelSetVerticalAlign(lbl_about_legth,"center")
   
    guiLabelSetHorizontalAlign(lbl_about_legth,"center",false)
   
   
    checkbox_save = guiCreateCheckBox(329,110,100,20,"(Save)",false,false,tab_Login)
   
    guiSetFont(checkbox_save,"default-small")
   
    btn_Login = guiCreateButton(164,162,147,41,"Login",false,tab_Login)
   
    guiSetFont(btn_Login,"default-bold-small")
   
   
    login_tab_error_msg = guiCreateLabel(31,131,419,25,"Error_login_tab",false,tab_Login)
   
    guiLabelSetColor(login_tab_error_msg,255,0,0)
   
    guiLabelSetVerticalAlign(login_tab_error_msg,"center")
   
    guiLabelSetHorizontalAlign(login_tab_error_msg,"center",false)
   
    guiSetFont(login_tab_error_msg,"default-bold-small")
   
       
        if GuestEnable == false then
        btnGuest = guiCreateButton(29,168,94,32,"Play as Guest",false,tab_Login)
        guiSetFont(btnGuest,"default-small")
        guiSetVisible(btnGuest,true)
   
        else
            if isElement(btnGuest) then
            guiSetVisible(btnGuest,false)
            end
        btnGuest = nil
        end
    tab_Register = guiCreateTab("Register",tabPannel_Main)
   
   
    lbl_account_name = guiCreateLabel(43,39,119,21,"Account Name:",false,tab_Register)
   
    guiLabelSetVerticalAlign(lbl_account_name,"center")
   
    guiLabelSetHorizontalAlign(lbl_account_name,"right",false)
   
    guiSetFont(lbl_account_name,"default-bold-small")
   
   
    lbl_reg_top_info = guiCreateLabel(66,5,364,31,"Please fill in all fields. Don't use any special characters.",false,tab_Register)
   
    guiLabelSetColor(lbl_reg_top_info,255,255,255)
   
    guiLabelSetVerticalAlign(lbl_reg_top_info,"center")
   
    guiLabelSetHorizontalAlign(lbl_reg_top_info,"center",false)
   
   
    edit_account_name = guiCreateEdit(172,40,176,23,"",false,tab_Register)
   
    guiEditSetMaxLength ( edit_account_name,25)
   
   
    lbl__reg_tab_password = guiCreateLabel(43,71,119,21,"Password:",false,tab_Register)
   
    guiLabelSetVerticalAlign(lbl__reg_tab_password,"center")
   
    guiLabelSetHorizontalAlign(lbl__reg_tab_password,"right",false)
   
    guiSetFont(lbl__reg_tab_password,"default-bold-small")
   
   
    edit__reg_tab_password = guiCreateEdit(172,71,176,23,"",false,tab_Register)
   
    guiEditSetMaxLength ( edit__reg_tab_password,25)
   
   
    edit__reg_tab_Repassword = guiCreateEdit(172,102,176,23,"",false,tab_Register)
   
    guiEditSetMaxLength ( edit__reg_tab_Repassword,25)
   
   
    lvl_reg_tab_Repassword = guiCreateLabel(43,102,119,21,"Repeat password:",false,tab_Register)
   
    guiLabelSetVerticalAlign(lvl_reg_tab_Repassword,"center")
   
    guiLabelSetHorizontalAlign(lvl_reg_tab_Repassword,"right",false)
   
    guiSetFont(lvl_reg_tab_Repassword,"default-bold-small")
   
   
    btn_reg_tab_register = guiCreateButton(153,161,174,42,"Confirm & register!",false,tab_Register)
   
    guiSetFont(btn_reg_tab_register,"default-bold-small")
   
   
    reg_tab_error_msg = guiCreateLabel(66,129,364,31,"Error_reg_ttab",false,tab_Register)
   
    guiLabelSetColor(reg_tab_error_msg,255,20,0)
   
    guiLabelSetVerticalAlign(reg_tab_error_msg,"center")
   
    guiLabelSetHorizontalAlign(reg_tab_error_msg,"center",false)
   
    guiSetFont(reg_tab_error_msg,"default-bold-small")
   
   
    guiSetVisible(wdwLogin_Pannel,true)
    --
    guiSetInputMode("no_binds_when_editing")   
    showCursor(true)
 
    guiSetText(reg_tab_error_msg, "")
    guiSetText(login_tab_error_msg, "") 
   
    local username, password = loadLoginFromXML()
   
   
        if not( username == "" or password == "") then     
        guiCheckBoxSetSelected ( checkbox_save, true )
       
        guiSetText ( edit_Login, tostring(username))
       
        guiSetText ( edit_password, tostring(password))
   
        else       
        guiCheckBoxSetSelected ( checkbox_save, false )
       
        guiSetText ( edit_Login, tostring(username))
       
        guiSetText ( edit_password, tostring(password))
   
        end 
    addEventHandler("onClientGUIClick",btn_Login,onClickBtnLogin)
    addEventHandler("onClientGUIClick",btn_reg_tab_register,onClickBtnRegister)
        if GuestEnable == true then
        addEventHandler("onClientGUIClick",btnGuest,onClickGuest)
        end 
   
--
    else    --
    destroyElement(wdwLogin_Pannel)
 --
    guiSetInputMode("no_binds_when_editing")    --
    wdwLogin_Pannel = nil
    --
    showCursor(false)
    fadeCamera(source, true, 5)
    setCameraMatrix(source, 1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316)
    end
end
 
       
       
function start_cl_resource()   
open_log_reg_pannel()
end
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),start_cl_resource)
 
addCommandHandler("loginpanel", start_cl_resource)
 
       
       
function loadLoginFromXML() 
local xml_save_log_File = xmlLoadFile ("files/xml/userdata.xml")
   
    if not xml_save_log_File then        
    xml_save_log_File = xmlCreateFile("files/xml/userdata.xml", "login")
   
    end    
local usernameNode = xmlFindChild (xml_save_log_File, "username", 0)
   
local passwordNode = xmlFindChild (xml_save_log_File, "password", 0)
   
    if usernameNode and passwordNode then
    return xmlNodeGetValue(usernameNode), xmlNodeGetValue(passwordNode)
    else
    return "", ""
   
   
Link to comment

This is impossible, please make sure you have copied full client side code from line 1 till line 47.

Server triggered clientside event onLogin, but event is not added clientside

You don't need to edit anything in the login panel.

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