Jump to content

outputChatBox is duplicating..


Recommended Posts

  
addEvent("spawnNewSecurity",true) 
addEventHandler("spawnNewSecurity",getRootElement(), 
function () 
    outputChatBox("#00CC00[PTP]#FFFFFF You spawned as security! Use /job to see your task!",source,0,0,0,true) 
    setElementData(source,"security","True") 
    local number = math.random(11) 
    if number == 1 then 
        spawnPlayer(source,1133.80859375,-2025.0445556641,69.000610351563,0,180,0) 
        setCameraTarget(source) 
        setElementModel(source,165) 
    elseif number == 2 then  
        spawnPlayer(source,1133.80859375,-2025.0445556641,69.000610351563,0,180,0) 
        setCameraTarget(source) 
        setElementModel(source,166) 
    elseif number == 3 then 
        spawnPlayer(source,1133.80859375,-2025.0445556641,69.000610351563,0,180,0) 
        setCameraTarget(source) 
        setElementModel(source,280) 
    elseif number == 4 then 
        spawnPlayer(source,1133.80859375,-2025.0445556641,69.000610351563,0,180,0) 
        setCameraTarget(source) 
        setElementModel(source,281) 
    elseif number == 5 then 
        spawnPlayer(source,1133.80859375,-2025.0445556641,69.000610351563,0,180,0) 
        setCameraTarget(source) 
        setElementModel(source,282) 
    elseif number == 6 then 
        spawnPlayer(source,1133.80859375,-2025.0445556641,69.000610351563,0,180,0) 
        setCameraTarget(source) 
        setElementModel(source,283) 
    elseif number == 7 then 
        spawnPlayer(source,1133.80859375,-2025.0445556641,69.000610351563,0,180,0) 
        setCameraTarget(source) 
        setElementModel(source,284) 
    elseif number == 8 then 
        spawnPlayer(source,1133.80859375,-2025.0445556641,69.000610351563,0,180,0) 
        setCameraTarget(source) 
        setElementModel(source,285) 
    elseif number == 9 then 
        spawnPlayer(source,1133.80859375,-2025.0445556641,69.000610351563,0,180,0) 
        setElementModel(source,286) 
    elseif number == 10 then 
        spawnPlayer(source,1133.80859375,-2025.0445556641,69.000610351563,0,180,0) 
        setCameraTarget(source) 
        setElementModel(source,287) 
    elseif number == 11 then 
        spawnPlayer(source,1133.80859375,-2025.0445556641,69.000610351563,0,180,0) 
        setCameraTarget(source) 
        setElementModel(source,288) 
    end 
end) 
  

This is the serverside code and

  
addEventHandler("onClientGUIClick",getRootElement(), 
function () 
    if source == Button_Security then 
        triggerServerEvent("spawnNewSecurity",getLocalPlayer()) 
    end 
end) 
  

this is client

There is nothing wrong or not?

Link to comment
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()), 
function ()
    addEventHandler("onClientRender",getRootElement(),
    function ()
        local x,y = guiGetScreenSize()
        dxDrawText("PTP 0.12 BETA", x*0.75,y*0.9, 1270, 923, tocolor(255, 255, 255, 255), 2.00, "pricedown", "left", "top", false, false, true, false, false)
    end);
end);
 
addEvent("setPlayersCamera",true);
addEventHandler("setPlayersCamera",getRootElement(),
function ()
    local matrix = setCameraMatrix(1572.1561279297,-1808.7569580078,76.464111328125,1475.1350097656,-1677.6148681641,13.301302909851);
    setTimer(getRandomCameraPos,10000,1);
    setTime(5,30);
    setWeather(1);
    setCloudsEnabled(false);
    showCursor(true);
end);
 
function getRandomCameraPos()
    if getElementData(getLocalPlayer(),"login") == "notLoggedIn" then
        local randomPos = math.random(5)
        if randomPos == 1 then
            setCameraMatrix(1028.6870117188,-2036.8507080078,109.07088470459,1172.0684814453,-2036.7298583984,68.401649475098);
            setTime(5,30);
            setTimer(getRandomCameraPos,10000,1);
        elseif randomPos == 2 then
            setCameraMatrix(220.54316711426,-2030.2954101563,46.9792137146,134.67477416992,-1884.3803710938,2.1879935264587);
            setTime(5,30);
            setTimer(getRandomCameraPos,10000,1);
        elseif randomPos == 3 then
            setCameraMatrix(1931.7719726563,1192.240234375,97.54972076416,2142.6896972656,1271.0296630859,15.921746253967);
            setTime(5,30);
            setTimer(getRandomCameraPos,10000,1);
        elseif randomPos == 4 then
            setCameraMatrix(2131.0710449219,921.58319091797,55.947288513184,2016.5047607422,1038.0780029297,10.486658096313);
            setTime(5,30);
            setTimer(getRandomCameraPos,10000,1);
        elseif randomPos == 5 then
            setCameraMatrix(1572.1561279297,-1808.7569580078,76.464111328125,1475.1350097656,-1677.6148681641,13.301302909851);
            setTime(5,30);
            setTimer(getRandomCameraPos,10000,1);
        end;
    end;
end;
 
    GUIEditor = {
        tab = {},
        tabpanel = {},
        edit = {},
        button = {},
        window = {},
        label = {},
        checkbox = {}
    }
addEvent("showStartGUI",true);
addEventHandler("showStartGUI",getRootElement(),
function ()
    local sW,sH = guiGetScreenSize()
    local lpW,lpH = 263, 295
    GUIEditor.window[1] = guiCreateWindow(sW/2-lpW/2, sH/2-lpH/2, lpW, lpH, "Welcome to PTP", false);
    guiWindowSetSizable(GUIEditor.window[1], false);
    guiSetAlpha(GUIEditor.window[1], 0.00);
   
    GUIEditor.tabpanel[1] = guiCreateTabPanel(9, 25, 244, 356, false, GUIEditor.window[1]);
   
    GUIEditor.tab[1] = guiCreateTab("Login", GUIEditor.tabpanel[1]);
   
    GUIEditor.edit[1] = guiCreateEdit(7, 49, 227, 34, "", false, GUIEditor.tab[1]);
    GUIEditor.label[1] = guiCreateLabel(7, 36, 227, 13, "Username", false, GUIEditor.tab[1]);
    guiSetFont(GUIEditor.label[1], "default-bold-small");
    guiLabelSetHorizontalAlign(GUIEditor.label[1], "center", false);
    GUIEditor.label[2] = guiCreateLabel(7, 13, 227, 13, "Please login to have all functions!", false, GUIEditor.tab[1]);
    guiSetFont(GUIEditor.label[2], "default-bold-small");
    guiLabelSetHorizontalAlign(GUIEditor.label[2], "center", false);
    GUIEditor.edit[2] = guiCreateEdit(7, 107, 227, 34, "", false, GUIEditor.tab[1]);
    guiEditSetMasked(GUIEditor.edit[2], true);
   
    GUIEditor.checkbox[1] = guiCreateCheckBox(7, 42, 15, 15, "", false, false, GUIEditor.edit[2]);
   
    GUIEditor.label[3] = guiCreateLabel(7, 93, 227, 13, "Password", false, GUIEditor.tab[1]);
    guiSetFont(GUIEditor.label[3], "default-bold-small");
    guiLabelSetHorizontalAlign(GUIEditor.label[3], "center", false);
    GUIEditor.checkbox[2] = guiCreateCheckBox(7, 151, 15, 15, "", true, false, GUIEditor.tab[1]);
    GUIEditor.label[4] = guiCreateLabel(26, 150, 153, 16, "Remember me", false, GUIEditor.tab[1]);
    guiSetFont(GUIEditor.label[4], "default-bold-small");
    GUIEditor.button[1] = guiCreateButton(9, 185, 229, 46, "Login and Play", false, GUIEditor.tab[1]);
    guiSetFont(GUIEditor.button[1], "default-bold-small");
    guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA");
   
    GUIEditor.tab[2] = guiCreateTab("Register", GUIEditor.tabpanel[1]);
   
    GUIEditor.label[5] = guiCreateLabel(5, 12, 234, 15, "Username", false, GUIEditor.tab[2]);
    guiSetFont(GUIEditor.label[5], "default-bold-small");
    guiLabelSetHorizontalAlign(GUIEditor.label[5], "center", false);
    GUIEditor.edit[3] = guiCreateEdit(7, 27, 227, 35, "", false, GUIEditor.tab[2]);
    GUIEditor.label[6] = guiCreateLabel(5, 72, 234, 15, "Password", false, GUIEditor.tab[2]);
    guiSetFont(GUIEditor.label[6], "default-bold-small");
    guiLabelSetHorizontalAlign(GUIEditor.label[6], "center", false);
    GUIEditor.edit[4] = guiCreateEdit(7, 87, 227, 35, "", false, GUIEditor.tab[2]);
    GUIEditor.edit[5] = guiCreateEdit(7, 148, 227, 35, "", false, GUIEditor.tab[2]);
    GUIEditor.label[7] = guiCreateLabel(5, 132, 234, 15, "Password Confirmation", false, GUIEditor.tab[2]);
    guiSetFont(GUIEditor.label[7], "default-bold-small");
    guiLabelSetHorizontalAlign(GUIEditor.label[7], "center", false);
    GUIEditor.button[2] = guiCreateButton(11, 191, 218, 42, "Register", false, GUIEditor.tab[2]);
    guiSetFont(GUIEditor.button[2], "default-bold-small");
    guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA");
   
    addEventHandler("onClientGUIClick",GUIEditor.button[1],loginFunctionClient,false);
    addEventHandler("onClientGUIClick",GUIEditor.button[2],registerFunctionClient,false);
    guiSetInputEnabled(true);
   
    local alpha = 0.00;
    setTimer(function()
        alpha = alpha + 0.02;
        guiSetAlpha(GUIEditor.window[1],alpha);
    end, 50, 50);   
end);
 
function loginFunctionClient()
    local username = guiGetText(GUIEditor.edit[1]);
    local password = guiGetText(GUIEditor.edit[2]);
    if string.len(username) >= 4 and string.len(username) <= 36 then
        if string.len(password) >= 4 and string.len(password) <= 36 then
            triggerServerEvent("loginIntoAccount",getLocalPlayer(),username,password);
            saveLoginToXML();
        else
            outputChatBox("#00CC00[PTP]#FFFFFF Invalid password length! Minimum: 4, Maximum: 36 !",0,0,0,true);
        end;
    else
        outputChatBox("#00CC00[PTP]#FFFFFF Invalid username length! Minimum: 4, Maximum: 36 !",0,0,0,true);
    end;
end;
 
function registerFunctionClient()
    local username = guiGetText(GUIEditor.edit[3]);
    local password = guiGetText(GUIEditor.edit[4]);
    local passwordconfirm = guiGetText(GUIEditor.edit[5]);
    if string.len(username) >= 4 and string.len(username) <= 36 then
        if string.len(password) >= 4 and string.len(password) <= 36 then
            if string.len(passwordconfirm) >= 4 and string.len(passwordconfirm) <= 36 then
                triggerServerEvent("registernewAccount",getLocalPlayer(),username,password,passwordconfirm);
            else
                outputChatBox("#00CC00[PTP]#FFFFFF Invalid passwordconfirm length! Minimum: 4, Maximum: 36 !",0,0,0,true);
            end;
        else
            outputChatBox("#00CC00[PTP]#FFFFFF Invalied password length! Minimum: 4, Maximum: 36 !",0,0,0,true);
        end;
    else
        outputChatBox("#00CC00[PTP]#FFFFFF Invalid username length! Minimum: 4, Maximum: 36 !",0,0,0,true);
    end;
end;
 
addEvent("fadeLoginGuiOut",true);
addEventHandler("fadeLoginGuiOut",getRootElement(),
function()
    outputChatBox("holiker")
    local alpha = 1.00;
    setTimer(function()
        alpha = alpha - 0.02;
        guiSetAlpha(GUIEditor.window[1],alpha);
    end, 50, 50);
    setTimer(function() destroyElement(GUIEditor.window[1]) fadeCamera(true) end, 3500, 1);
    triggerServerEvent("spawnPlayerForSkinChange",getLocalPlayer());
end);
 
function saveLoginToXML()
    local username = guiGetText(GUIEditor.edit[1]);
    local password = guiGetText(GUIEditor.edit[2]);
    local xmlFile = xmlLoadFile("accountdata.xml");
    if not xmlFile then
        xmlFile = xmlCreateFile("accountdata.xml","settings");
    end;
    xmlNodeSetAttribute(xmlFile,"username",tostring(username));
    xmlNodeSetAttribute(xmlFile,"password",tostring(password));
    xmlNodeSetAttribute(xmlFile,"saved","true");
    xmlSaveFile(xmlFile);
    xmlUnloadFile(xmlFile);
end;
 
addEvent("showFractionMenu",true);
addEventHandler("showFractionMenu",getRootElement(),
function ()
    local x, y = guiGetScreenSize()
    local x2,y2 = 599, 178
    PTP_Window_Fraction = guiCreateWindow(x/2-x2/2, 0, x2, y2, "PTP 0.12 BETA Fraction Menu", false)
    guiWindowSetSizable(PTP_Window_Fraction, false)
    guiSetAlpha(PTP_Window_Fraction,0.00)
    guiSetVisible(PTP_Window_Fraction,true)
   
    local alpha = 0.00
    setTimer(function()
        alpha = alpha + 0.02
        guiSetAlpha(PTP_Window_Fraction, alpha)
    end, 50, 50)
   
    GUIEditor.label[1] = guiCreateLabel(19, 21, 557, 15, "You can choose between different fractions. Please choose your fraction now!", false, PTP_Window_Fraction)
    guiSetFont(GUIEditor.label[1], "default-bold-small")
    guiLabelSetHorizontalAlign(GUIEditor.label[1], "center", false)
    GUIEditor.label[2] = guiCreateLabel(203, 50, 100, 15, "President Status:", false, PTP_Window_Fraction)
    guiSetFont(GUIEditor.label[2], "default-bold-small")
    GUIEditor.label[3] = guiCreateLabel(181, 65, 122, 15, "Vicepresident Status:", false, PTP_Window_Fraction)
    guiSetFont(GUIEditor.label[3], "default-bold-small")
    GUIEditor.label[4] = guiCreateLabel(307, 50, 84, 15, "AVIABLE", false, PTP_Window_Fraction)
    guiSetFont(GUIEditor.label[4], "default-bold-small")
    guiLabelSetColor(GUIEditor.label[4], 35, 255, 0)
    GUIEditor.label[5] = guiCreateLabel(307, 65, 84, 15, "UNAVIABLE", false, PTP_Window_Fraction)
    guiSetFont(GUIEditor.label[5], "default-bold-small")
    guiLabelSetColor(GUIEditor.label[5], 248, 6, 6)
    GUIEditor.button[1] = guiCreateButton(9, 129, 109, 39, "President", false, PTP_Window_Fraction)
    guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA")
    GUIEditor.button[2] = guiCreateButton(128, 129, 109, 39, "Vicepresident", false, PTP_Window_Fraction)
    guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA")
    GUIEditor.button[3] = guiCreateButton(247, 129, 109, 39, "Security", false, PTP_Window_Fraction)
    guiSetProperty(GUIEditor.button[3], "NormalTextColour", "FFAAAAAA")
    GUIEditor.button[4] = guiCreateButton(366, 129, 109, 39, "Terrorist", false, PTP_Window_Fraction)
    guiSetProperty(GUIEditor.button[4], "NormalTextColour", "FFAAAAAA")
    GUIEditor.button[5] = guiCreateButton(487, 129, 104, 39, "Civilian", false, PTP_Window_Fraction)
    guiSetProperty(GUIEditor.button[5], "NormalTextColour", "FFAAAAAA")
    GUIEditor.label[6] = guiCreateLabel(104, 104, 381, 15, "Skin will be randomly picked up!", false, PTP_Window_Fraction)
    guiSetFont(GUIEditor.label[6], "default-bold-small")
    guiLabelSetHorizontalAlign(GUIEditor.label[6], "center", false)
    addEventHandler("onClientRender",getRootElement(),checkFraction)
   
    showCursor(true)
    addEventHandler("onClientGUIClick",getRootElement(),
    function ()
        if source == GUIEditor.button[1] then
            if guiGetText(GUIEditor.label[4]) == "AVAILABLE" then
                triggerServerEvent("spawnNewPresident",getLocalPlayer())
            elseif guiGetText(GUIEditor.label[4]) == "NOT AVAILABLE" then
                outputChatBox("#00CC00[PTP]#FFFFFF President is currently not available!",0,0,0,true)
            end
        elseif source == GUIEditor.button[2] then
            if guiGetText(GUIEditor.label[5]) == "AVAILABLE" then
                --
            elseif guiGetText(GUIEditor.label[5]) == "NOT AVAILABLE" then
                outputChatBox("#00CC00[PTP]#FFFFFF Vicepresident is currently not available!",0,0,0,true)
            end
        elseif source == GUIEditor.button[3] then
            triggerServerEvent("spawnNewSecurity",getLocalPlayer())
        elseif source == GUIEditor.button[4] then
            --
        elseif source == GUIEditor.button[5] then
            --
        end
    end)
end);
addCommandHandler("skin",function() triggerEvent("showFractionMenu",getLocalPlayer()) end); -- DEBUG
 
Link to comment

Got it, you are adding the event handler for the onClientGUIClick over and over again.

addEventHandler("onClientRender",getRootElement(), 
    function ()
        local x,y = guiGetScreenSize()
        dxDrawText("PTP 0.12 BETA", x*0.75,y*0.9, 1270, 923, tocolor(255, 255, 255, 255), 2.00, "pricedown", "left", "top", false, false, true, false, false)
    end
);
 
addEvent("setPlayersCamera",true);
addEventHandler("setPlayersCamera",getRootElement(),
function ()
    local matrix = setCameraMatrix(1572.1561279297,-1808.7569580078,76.464111328125,1475.1350097656,-1677.6148681641,13.301302909851);
    setTimer(getRandomCameraPos,10000,1);
    setTime(5,30);
    setWeather(1);
    setCloudsEnabled(false);
    showCursor(true);
end);
 
function getRandomCameraPos()
    if getElementData(getLocalPlayer(),"login") == "notLoggedIn" then
        local randomPos = math.random(5)
        if randomPos == 1 then
            setCameraMatrix(1028.6870117188,-2036.8507080078,109.07088470459,1172.0684814453,-2036.7298583984,68.401649475098);
            setTime(5,30);
            setTimer(getRandomCameraPos,10000,1);
        elseif randomPos == 2 then
            setCameraMatrix(220.54316711426,-2030.2954101563,46.9792137146,134.67477416992,-1884.3803710938,2.1879935264587);
            setTime(5,30);
            setTimer(getRandomCameraPos,10000,1);
        elseif randomPos == 3 then
            setCameraMatrix(1931.7719726563,1192.240234375,97.54972076416,2142.6896972656,1271.0296630859,15.921746253967);
            setTime(5,30);
            setTimer(getRandomCameraPos,10000,1);
        elseif randomPos == 4 then
            setCameraMatrix(2131.0710449219,921.58319091797,55.947288513184,2016.5047607422,1038.0780029297,10.486658096313);
            setTime(5,30);
            setTimer(getRandomCameraPos,10000,1);
        elseif randomPos == 5 then
            setCameraMatrix(1572.1561279297,-1808.7569580078,76.464111328125,1475.1350097656,-1677.6148681641,13.301302909851);
            setTime(5,30);
            setTimer(getRandomCameraPos,10000,1);
        end;
    end;
end;
 
    GUIEditor = {
        tab = {},
        tabpanel = {},
        edit = {},
        button = {},
        window = {},
        label = {},
        checkbox = {}
    }
addEvent("showStartGUI",true);
addEventHandler("showStartGUI",getRootElement(),
function ()
    local sW,sH = guiGetScreenSize()
    local lpW,lpH = 263, 295
    GUIEditor.window[1] = guiCreateWindow(sW/2-lpW/2, sH/2-lpH/2, lpW, lpH, "Welcome to PTP", false);
    guiWindowSetSizable(GUIEditor.window[1], false);
    guiSetAlpha(GUIEditor.window[1], 0.00);
   
    GUIEditor.tabpanel[1] = guiCreateTabPanel(9, 25, 244, 356, false, GUIEditor.window[1]);
   
    GUIEditor.tab[1] = guiCreateTab("Login", GUIEditor.tabpanel[1]);
   
    GUIEditor.edit[1] = guiCreateEdit(7, 49, 227, 34, "", false, GUIEditor.tab[1]);
    GUIEditor.label[1] = guiCreateLabel(7, 36, 227, 13, "Username", false, GUIEditor.tab[1]);
    guiSetFont(GUIEditor.label[1], "default-bold-small");
    guiLabelSetHorizontalAlign(GUIEditor.label[1], "center", false);
    GUIEditor.label[2] = guiCreateLabel(7, 13, 227, 13, "Please login to have all functions!", false, GUIEditor.tab[1]);
    guiSetFont(GUIEditor.label[2], "default-bold-small");
    guiLabelSetHorizontalAlign(GUIEditor.label[2], "center", false);
    GUIEditor.edit[2] = guiCreateEdit(7, 107, 227, 34, "", false, GUIEditor.tab[1]);
    guiEditSetMasked(GUIEditor.edit[2], true);
   
    GUIEditor.checkbox[1] = guiCreateCheckBox(7, 42, 15, 15, "", false, false, GUIEditor.edit[2]);
   
    GUIEditor.label[3] = guiCreateLabel(7, 93, 227, 13, "Password", false, GUIEditor.tab[1]);
    guiSetFont(GUIEditor.label[3], "default-bold-small");
    guiLabelSetHorizontalAlign(GUIEditor.label[3], "center", false);
    GUIEditor.checkbox[2] = guiCreateCheckBox(7, 151, 15, 15, "", true, false, GUIEditor.tab[1]);
    GUIEditor.label[4] = guiCreateLabel(26, 150, 153, 16, "Remember me", false, GUIEditor.tab[1]);
    guiSetFont(GUIEditor.label[4], "default-bold-small");
    GUIEditor.button[1] = guiCreateButton(9, 185, 229, 46, "Login and Play", false, GUIEditor.tab[1]);
    guiSetFont(GUIEditor.button[1], "default-bold-small");
    guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA");
   
    GUIEditor.tab[2] = guiCreateTab("Register", GUIEditor.tabpanel[1]);
   
    GUIEditor.label[5] = guiCreateLabel(5, 12, 234, 15, "Username", false, GUIEditor.tab[2]);
    guiSetFont(GUIEditor.label[5], "default-bold-small");
    guiLabelSetHorizontalAlign(GUIEditor.label[5], "center", false);
    GUIEditor.edit[3] = guiCreateEdit(7, 27, 227, 35, "", false, GUIEditor.tab[2]);
    GUIEditor.label[6] = guiCreateLabel(5, 72, 234, 15, "Password", false, GUIEditor.tab[2]);
    guiSetFont(GUIEditor.label[6], "default-bold-small");
    guiLabelSetHorizontalAlign(GUIEditor.label[6], "center", false);
    GUIEditor.edit[4] = guiCreateEdit(7, 87, 227, 35, "", false, GUIEditor.tab[2]);
    GUIEditor.edit[5] = guiCreateEdit(7, 148, 227, 35, "", false, GUIEditor.tab[2]);
    GUIEditor.label[7] = guiCreateLabel(5, 132, 234, 15, "Password Confirmation", false, GUIEditor.tab[2]);
    guiSetFont(GUIEditor.label[7], "default-bold-small");
    guiLabelSetHorizontalAlign(GUIEditor.label[7], "center", false);
    GUIEditor.button[2] = guiCreateButton(11, 191, 218, 42, "Register", false, GUIEditor.tab[2]);
    guiSetFont(GUIEditor.button[2], "default-bold-small");
    guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA");
   
    addEventHandler("onClientGUIClick",GUIEditor.button[1],loginFunctionClient,false);
    addEventHandler("onClientGUIClick",GUIEditor.button[2],registerFunctionClient,false);
    guiSetInputEnabled(true);
   
    local alpha = 0.00;
    setTimer(function()
        alpha = alpha + 0.02;
        guiSetAlpha(GUIEditor.window[1],alpha);
    end, 50, 50);  
end);
 
function loginFunctionClient()
    local username = guiGetText(GUIEditor.edit[1]);
    local password = guiGetText(GUIEditor.edit[2]);
    if string.len(username) >= 4 and string.len(username) <= 36 then
        if string.len(password) >= 4 and string.len(password) <= 36 then
            triggerServerEvent("loginIntoAccount",getLocalPlayer(),username,password);
            saveLoginToXML();
        else
            outputChatBox("#00CC00[PTP]#FFFFFF Invalid password length! Minimum: 4, Maximum: 36 !",0,0,0,true);
        end;
    else
        outputChatBox("#00CC00[PTP]#FFFFFF Invalid username length! Minimum: 4, Maximum: 36 !",0,0,0,true);
    end;
end;
 
function registerFunctionClient()
    local username = guiGetText(GUIEditor.edit[3]);
    local password = guiGetText(GUIEditor.edit[4]);
    local passwordconfirm = guiGetText(GUIEditor.edit[5]);
    if string.len(username) >= 4 and string.len(username) <= 36 then
        if string.len(password) >= 4 and string.len(password) <= 36 then
            if string.len(passwordconfirm) >= 4 and string.len(passwordconfirm) <= 36 then
                triggerServerEvent("registernewAccount",getLocalPlayer(),username,password,passwordconfirm);
            else
                outputChatBox("#00CC00[PTP]#FFFFFF Invalid passwordconfirm length! Minimum: 4, Maximum: 36 !",0,0,0,true);
            end;
        else
            outputChatBox("#00CC00[PTP]#FFFFFF Invalied password length! Minimum: 4, Maximum: 36 !",0,0,0,true);
        end;
    else
        outputChatBox("#00CC00[PTP]#FFFFFF Invalid username length! Minimum: 4, Maximum: 36 !",0,0,0,true);
    end;
end;
 
addEvent("fadeLoginGuiOut",true);
addEventHandler("fadeLoginGuiOut",getRootElement(),
function()
    outputChatBox("holiker")
    local alpha = 1.00;
    setTimer(function()
        alpha = alpha - 0.02;
        guiSetAlpha(GUIEditor.window[1],alpha);
    end, 50, 50);
    setTimer(function() destroyElement(GUIEditor.window[1]) fadeCamera(true) end, 3500, 1);
    triggerServerEvent("spawnPlayerForSkinChange",getLocalPlayer());
end);
 
function saveLoginToXML()
    local username = guiGetText(GUIEditor.edit[1]);
    local password = guiGetText(GUIEditor.edit[2]);
    local xmlFile = xmlLoadFile("accountdata.xml");
    if not xmlFile then
        xmlFile = xmlCreateFile("accountdata.xml","settings");
    end;
    xmlNodeSetAttribute(xmlFile,"username",tostring(username));
    xmlNodeSetAttribute(xmlFile,"password",tostring(password));
    xmlNodeSetAttribute(xmlFile,"saved","true");
    xmlSaveFile(xmlFile);
    xmlUnloadFile(xmlFile);
end;
 
addEvent("showFractionMenu",true);
addEventHandler("showFractionMenu",getRootElement(),
function ()
    local x, y = guiGetScreenSize()
    local x2,y2 = 599, 178
    PTP_Window_Fraction = guiCreateWindow(x/2-x2/2, 0, x2, y2, "PTP 0.12 BETA Fraction Menu", false)
    guiWindowSetSizable(PTP_Window_Fraction, false)
    guiSetAlpha(PTP_Window_Fraction,0.00)
    guiSetVisible(PTP_Window_Fraction,true)
   
    local alpha = 0.00
    setTimer(function()
        alpha = alpha + 0.02
        guiSetAlpha(PTP_Window_Fraction, alpha)
    end, 50, 50)
   
    GUIEditor.label[1] = guiCreateLabel(19, 21, 557, 15, "You can choose between different fractions. Please choose your fraction now!", false, PTP_Window_Fraction)
    guiSetFont(GUIEditor.label[1], "default-bold-small")
    guiLabelSetHorizontalAlign(GUIEditor.label[1], "center", false)
    GUIEditor.label[2] = guiCreateLabel(203, 50, 100, 15, "President Status:", false, PTP_Window_Fraction)
    guiSetFont(GUIEditor.label[2], "default-bold-small")
    GUIEditor.label[3] = guiCreateLabel(181, 65, 122, 15, "Vicepresident Status:", false, PTP_Window_Fraction)
    guiSetFont(GUIEditor.label[3], "default-bold-small")
    GUIEditor.label[4] = guiCreateLabel(307, 50, 84, 15, "AVIABLE", false, PTP_Window_Fraction)
    guiSetFont(GUIEditor.label[4], "default-bold-small")
    guiLabelSetColor(GUIEditor.label[4], 35, 255, 0)
    GUIEditor.label[5] = guiCreateLabel(307, 65, 84, 15, "UNAVIABLE", false, PTP_Window_Fraction)
    guiSetFont(GUIEditor.label[5], "default-bold-small")
    guiLabelSetColor(GUIEditor.label[5], 248, 6, 6)
    GUIEditor.button[1] = guiCreateButton(9, 129, 109, 39, "President", false, PTP_Window_Fraction)
    guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA")
    GUIEditor.button[2] = guiCreateButton(128, 129, 109, 39, "Vicepresident", false, PTP_Window_Fraction)
    guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA")
    GUIEditor.button[3] = guiCreateButton(247, 129, 109, 39, "Security", false, PTP_Window_Fraction)
    guiSetProperty(GUIEditor.button[3], "NormalTextColour", "FFAAAAAA")
    GUIEditor.button[4] = guiCreateButton(366, 129, 109, 39, "Terrorist", false, PTP_Window_Fraction)
    guiSetProperty(GUIEditor.button[4], "NormalTextColour", "FFAAAAAA")
    GUIEditor.button[5] = guiCreateButton(487, 129, 104, 39, "Civilian", false, PTP_Window_Fraction)
    guiSetProperty(GUIEditor.button[5], "NormalTextColour", "FFAAAAAA")
    GUIEditor.label[6] = guiCreateLabel(104, 104, 381, 15, "Skin will be randomly picked up!", false, PTP_Window_Fraction)
    guiSetFont(GUIEditor.label[6], "default-bold-small")
    guiLabelSetHorizontalAlign(GUIEditor.label[6], "center", false)
    addEventHandler("onClientRender",getRootElement(),checkFraction)
   
    showCursor(true)
end);
addCommandHandler("skin",function() triggerEvent("showFractionMenu",getLocalPlayer()) end); -- DEBUG
 
    addEventHandler("onClientGUIClick",getRootElement(),
    function ()
        if source == GUIEditor.button[1] then
            if guiGetText(GUIEditor.label[4]) == "AVAILABLE" then
                triggerServerEvent("spawnNewPresident",getLocalPlayer())
            elseif guiGetText(GUIEditor.label[4]) == "NOT AVAILABLE" then
                outputChatBox("#00CC00[PTP]#FFFFFF President is currently not available!",0,0,0,true)
            end
        elseif source == GUIEditor.button[2] then
            if guiGetText(GUIEditor.label[5]) == "AVAILABLE" then
                --
            elseif guiGetText(GUIEditor.label[5]) == "NOT AVAILABLE" then
                outputChatBox("#00CC00[PTP]#FFFFFF Vicepresident is currently not available!",0,0,0,true)
            end
        elseif source == GUIEditor.button[3] then
            triggerServerEvent("spawnNewSecurity",getLocalPlayer())
        elseif source == GUIEditor.button[4] then
            --
        elseif source == GUIEditor.button[5] then
            --
        end
    end)
 
function checkFraction()
   
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...