Jump to content

Problems


Jaysds1

Recommended Posts

  • Replies 365
  • Created
  • Last Reply

Top Posters In This Topic

When a player joins/spawns on a team the Image and the Text for the Team is suppose to show then fadeout after 15 seconds.

Server-side:

  
            if (getPlayerTeam(client)) and (getTeamFromName(Teams[1])) then 
                triggerClientEvent(client,"BOPS", getRootElement()) 
            elseif (getPlayerTeam(client)) and (getTeamFromName(Teams[2])) then 
                triggerClientEvent(client,"Spets",getRootElement()) 
            elseif (getPlayerTeam(client)) and (getTeamFromName(Teams[3])) then 
                triggerClientEvent(client,"SOG",getRootElement()) 
            elseif (getPlayerTeam(client)) and (getTeamFromName(Teams[4])) then 
                triggerClientEvent(client,"NVA",getRootElement()) 
            elseif (getPlayerTeam(client)) and (getTeamFromName(Teams[5])) then 
                triggerClientEvent(client,"Tpas",getRootElement()) 
            elseif (getPlayerTeam(client)) and (getTeamFromName(Teams[6])) then 
                triggerClientEvent(client,"O40",getRootElement()) 
            end 
  

Client-side

  
function Tro() 
    dxDrawImage(316.0,241.0,129.0,114.0,"tropas.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
    dxDrawText("Tropas",327.0,175.0,427.0,231.0,tocolor(255,255,255,255),2.0,"default","center","center",false,false,false) 
end 
addEventHandler("onClientRender",root, Tro) 
addEvent("Tpas",true) 
addEventHandler("Tpas", getRootElement(), Tro) 
setTimer ( Tro, 13000, 1) 
  
    function Snaz() 
        dxDrawImage(325.0,231.0,103.0,99.0,"spetsnaz.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
        dxDrawText("Spetsnaz",327.0,175.0,427.0,231.0,tocolor(255,255,255,255),2.0,"default","center","center",false,false,false) 
    end 
addEventHandler("onClientRender",root, Snaz) 
addEvent("Spets",true) 
addEventHandler("Spets", getRootElement(), Snaz) 
setTimer ( Snaz, 13000, 1) 
  
    function P40() 
        dxDrawImage(318.0,231.0,134.0,122.0,"op40.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
        dxDrawText("OP40",327.0,175.0,427.0,231.0,tocolor(255,255,255,255),3.0,"default","center","center",false,false,false) 
    end 
addEventHandler("onClientRender",root, P40) 
addEvent("O40",true) 
addEventHandler("O40", getRootElement(), P40) 
setTimer ( P40, 13000, 1) 
  
    function OPS() 
        dxDrawImage(309.0,231.0,134.0,121.0,"black ops.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
        dxDrawText("Black OPS",327.0,175.0,427.0,231.0,tocolor(255,255,255,255),3.0,"default","center","center",false,false,false) 
    end 
addEventHandler("onClientRender",root, OPS) 
addEvent("BOPS",true) 
addEventHandler("BOPS", getRootElement(), OPS) 
setTimer ( OPS, 13000, 1) 
  
    function nva() 
        dxDrawText("NVA",327.0,175.0,427.0,231.0,tocolor(255,255,255,255),4.0,"default","center","center",false,false,false) 
        dxDrawImage(312.0,227.0,127.0,143.0,"nva.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
    end 
addEventHandler("onClientRender",root, nva) 
addEvent("NVA",true) 
addEventHandler("NVA", getRootElement(), nva) 
setTimer ( nva, 13000, 1) 
  

Link to comment

server side

            if (getPlayerTeam(client) == getTeamFromName(Teams[1])) then 
                triggerClientEvent(client,"BOPS", getRootElement()) 
            elseif (getPlayerTeam(client) == getTeamFromName(Teams[2])) then 
                triggerClientEvent(client,"Spets",getRootElement()) 
            elseif (getPlayerTeam(client) == getTeamFromName(Teams[3])) then 
                triggerClientEvent(client,"SOG",getRootElement()) 
            elseif (getPlayerTeam(client) == getTeamFromName(Teams[4])) then 
                triggerClientEvent(client,"NVA",getRootElement()) 
            elseif (getPlayerTeam(client) == getTeamFromName(Teams[5])) then 
                triggerClientEvent(client,"Tpas",getRootElement()) 
            elseif (getPlayerTeam(client) == getTeamFromName(Teams[6])) then 
                triggerClientEvent(client,"O40",getRootElement()) 
            end 

client side

function Tro() 
    dxDrawImage(316.0,241.0,129.0,114.0,"tropas.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
    dxDrawText("Tropas",327.0,175.0,427.0,231.0,tocolor(255,255,255,255),2.0,"default","center","center",false,false,false) 
end 
  
addEvent("Tpas",true) 
addEventHandler("Tpas", getRootElement(), function () addEventHandler("onClientRender",root, Tro) setTimer ( removeEventHandler , 13000, 1, "onClientRender",root, Tro) end) 
  
    function Snaz() 
        dxDrawImage(325.0,231.0,103.0,99.0,"spetsnaz.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
        dxDrawText("Spetsnaz",327.0,175.0,427.0,231.0,tocolor(255,255,255,255),2.0,"default","center","center",false,false,false) 
    end 
  
addEvent("Spets",true) 
addEventHandler("Spets", getRootElement(), function() addEventHandler("onClientRender",root, Snaz) setTimer ( removeEventHandler, 13000, 1, "onClientRender",root, Snaz) end) 
  
  
    function P40() 
        dxDrawImage(318.0,231.0,134.0,122.0,"op40.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
        dxDrawText("OP40",327.0,175.0,427.0,231.0,tocolor(255,255,255,255),3.0,"default","center","center",false,false,false) 
    end 
  
addEvent("O40",true) 
addEventHandler("O40", getRootElement(), function() addEventHandler("onClientRender",root, P40) setTimer ( removeEventHandler, 13000, 1, "onClientRender",root, P40) end) 
  
  
    function OPS() 
        dxDrawImage(309.0,231.0,134.0,121.0,"black ops.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
        dxDrawText("Black OPS",327.0,175.0,427.0,231.0,tocolor(255,255,255,255),3.0,"default","center","center",false,false,false) 
    end 
  
addEvent("BOPS",true) 
addEventHandler("BOPS", getRootElement(), function() addEventHandler("onClientRender",root, OPS) setTimer ( removeEventHandler, 13000, 1, "onClientRender",root, OPS)) 
  
  
    function nva() 
        dxDrawText("NVA",327.0,175.0,427.0,231.0,tocolor(255,255,255,255),4.0,"default","center","center",false,false,false) 
        dxDrawImage(312.0,227.0,127.0,143.0,"nva.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
    end 
  
addEvent("NVA",true) 
addEventHandler("NVA", getRootElement(), function() addEventHandler("onClientRender",root, nva)setTimer(removeEventHandler, 13000, 1,  "onClientRender",root, nva) 

Link to comment

I edited it and now the image isn't being shown.

Client-side only:

  
-- Teams 
  
  
function Tro() 
    dxDrawImage(316.0,241.0,129.0,114.0,"tropas.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
    dxDrawText("Tropas",327.0,175.0,427.0,231.0,tocolor(255,255,255,255),2.0,"default","center","center",false,false,false) 
end 
  
addEvent("Tpas",true) 
addEventHandler("Tpas", getRootElement(),  
function()  
addEventHandler("onClientRender",root, Tro)  
setTimer (Tro ,13000, 1, removeEventHandler("onClientRender",root, Tro))  
end) 
  
    function Snaz() 
        dxDrawImage(325.0,231.0,103.0,99.0,"spetsnaz.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
        dxDrawText("Spetsnaz",327.0,175.0,427.0,231.0,tocolor(255,255,255,255),2.0,"default","center","center",false,false,false) 
    end 
  
addEvent("Spets",true) 
addEventHandler("Spets", getRootElement(),  
function()  
addEventHandler("onClientRender",root, Snaz)  
setTimer (Snaz ,13000, 1, removeEventHandler("onClientRender",root, Snaz))  
end) 
  
  
    function P40() 
        dxDrawImage(318.0,231.0,134.0,122.0,"op40.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
        dxDrawText("OP40",327.0,175.0,427.0,231.0,tocolor(255,255,255,255),3.0,"default","center","center",false,false,false) 
    end 
  
addEvent("O40",true) 
addEventHandler("O40", getRootElement(), 
 function() 
 addEventHandler("onClientRender",root, P40) 
 setTimer (P40 ,13000, 1, removeEventHandler("onClientRender",root, P40))  
 end) 
  
  
    function OPS() 
        dxDrawImage(309.0,231.0,134.0,121.0,"black ops.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
        dxDrawText("Black OPS",327.0,175.0,427.0,231.0,tocolor(255,255,255,255),3.0,"default","center","center",false,false,false) 
    end 
  
addEvent("BOPS",true) 
addEventHandler("BOPS", getRootElement(),  
function()  
addEventHandler("onClientRender",root, OPS)  
setTimer (OPS ,13000, 1, removeEventHandler("onClientRender",root, OPS))  
end) 
  
  
    function nva() 
        dxDrawText("NVA",327.0,175.0,427.0,231.0,tocolor(255,255,255,255),4.0,"default","center","center",false,false,false) 
        dxDrawImage(312.0,227.0,127.0,143.0,"nva.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
    end 
  
addEvent("NVA",true) 
addEventHandler("NVA", getRootElement(),  
function()  
addEventHandler("onClientRender",root, nva)  
setTimer (nva ,13000, 1, removeEventHandler("onClientRender",root, nva))  
end) 
  

Link to comment
-- Teams 
  
  
function Tro() 
    dxDrawImage(316.0,241.0,129.0,114.0,"tropas.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
    dxDrawText("Tropas",327.0,175.0,427.0,231.0,tocolor(255,255,255,255),2.0,"default","center","center",false,false,false) 
end 
  
addEvent("Tpas",true) 
addEventHandler("Tpas", getRootElement(), 
function() 
addEventHandler("onClientRender",root, Tro) 
setTimer (removeEventHandler,13000, 1, "onClientRender",root, Tro) 
end) 
  
    function Snaz() 
        dxDrawImage(325.0,231.0,103.0,99.0,"spetsnaz.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
        dxDrawText("Spetsnaz",327.0,175.0,427.0,231.0,tocolor(255,255,255,255),2.0,"default","center","center",false,false,false) 
    end 
  
addEvent("Spets",true) 
addEventHandler("Spets", getRootElement(), 
function() 
addEventHandler("onClientRender",root, Snaz) 
setTimer (removeEventHandler,13000, 1, "onClientRender",root, Snaz) 
end) 
  
  
    function P40() 
        dxDrawImage(318.0,231.0,134.0,122.0,"op40.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
        dxDrawText("OP40",327.0,175.0,427.0,231.0,tocolor(255,255,255,255),3.0,"default","center","center",false,false,false) 
    end 
  
addEvent("O40",true) 
addEventHandler("O40", getRootElement(), 
 function() 
 addEventHandler("onClientRender",root, P40) 
 setTimer (removeEventHandler,13000, 1, "onClientRender",root, P40) 
 end) 
  
  
    function OPS() 
        dxDrawImage(309.0,231.0,134.0,121.0,"black ops.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
        dxDrawText("Black OPS",327.0,175.0,427.0,231.0,tocolor(255,255,255,255),3.0,"default","center","center",false,false,false) 
    end 
  
addEvent("BOPS",true) 
addEventHandler("BOPS", getRootElement(), 
function() 
addEventHandler("onClientRender",root, OPS) 
setTimer (removeEventHandler,13000, 1, "onClientRender",root, OPS) 
end) 
  
  
    function nva() 
        dxDrawText("NVA",327.0,175.0,427.0,231.0,tocolor(255,255,255,255),4.0,"default","center","center",false,false,false) 
        dxDrawImage(312.0,227.0,127.0,143.0,"nva.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
    end 
  
addEvent("NVA",true) 
addEventHandler("NVA", getRootElement(), 
function() 
addEventHandler("onClientRender",root, nva) 
setTimer (removeEventHandler,13000, 1, "onClientRender",root, nva) 
end) 

Link to comment
-- client side 
local username = guiGetText(usernameEditBox) 
local pass = guiGetText(passEditBox) 
triggerServerEvent("register", root, username, pass) 
  
--server side 
addEvent("register", true) 
addEventHandler("register", root, 
function(username, pass) 
if client then 
addAccount(username, pass) 
end 
end) 

There should be more checking so the player won't leave the edit box empty.

Link to comment

I have this script, when I type in /save it's suppose to save the players Position.

Client-side:

  
    addCommandHandler ( "save", 
    function(player) 
    local vehicle = getPedOccupiedVehicle(getLocalPlayer()) 
    local player = getElementType(player) 
        if (vehicle) then 
            local x, y, z = getElementPosition(getLocalPlayer()) 
            local model = getElementModel(vehicle) 
            local code1 = x, y, z, model 
            outputChatBox ("Saved ",source) 
            triggerServerEvent("savevehicle",getLocalPlayer(),code1) 
        elseif (player) then 
            local x, y, z = getElementPosition(getLocalPlayer()) 
            local code = x, y, z 
            triggerServerEvent("saveplayer",getLocalPlayer(),code) 
        end 
    end) 
  

Server-side:

  
addEvent("saveplayer",true) 
addEventHandler("saveplayer",root, 
function(text,valuetype) 
    local file = fileOpen("positions.txt")  
     
    if not file then 
        file = fileCreate("positions.txt") 
        outputDebugString("Creating positions.txt") 
    end 
     
    if file then     
        local time = getRealTime() 
     
        fileSetPos(file,fileGetSize(file)) 
        local written = fileWrite(file,"\r\n",string.format("-- Created: %02s/%02s/%04s %02s:%02s\r\n", 
                        tostring(time.monthday), 
                        tostring(time.month + 1), 
                        tostring(time.year + 1900), 
                        tostring(time.hour), 
                        tostring(time.minute)),      
                        text,"\r\n--- --- --- --- ---\r\n") 
        fileFlush(file) 
        fileClose(file) 
        if written then 
            outputChatBox("Succesfully saved to positions.txt",source) 
            outputChatBox(valuetype,source) 
        end 
    else 
        outputDebugString("Save: Cannot find or create positions.txt") 
    end 
end) 
  
addEvent("savevehicle",true) 
addEventHandler("savevehicle",root, 
function(text,valuetype) 
    local file = fileOpen("positions.txt")  
     
    if not file then 
        file = fileCreate("positions.txt") 
        outputDebugString("Creating positions.txt") 
    end 
     
    if file then     
        local time = getRealTime() 
     
        fileSetPos(file,fileGetSize(file)) 
        local written = fileWrite(file,"\r\n",string.format("-- Created: %02s/%02s/%04s %02s:%02s\r\n", 
                        tostring(time.monthday), 
                        tostring(time.month + 1), 
                        tostring(time.year + 1900), 
                        tostring(time.hour), 
                        tostring(time.minute)),      
                        text,"\r\n--- --- --- --- ---\r\n") 
        fileFlush(file) 
        fileClose(file) 
        if written then 
            outputChatBox("Succesfully saved to positions.txt",source) 
            outputChatBox(valuetype,source) 
        end 
    else 
        outputDebugString("Save: Cannot find or create positions.txt") 
    end 
end) 
  

Link to comment

client side:

  addCommandHandler ( "save", 
    function() 
    local vehicle = getPedOccupiedVehicle(getLocalPlayer()) 
        if (vehicle) then 
            local x, y, z = getElementPosition(getLocalPlayer()) 
            local model = getElementModel(vehicle) 
            local code1 = x, y, z, model 
            outputChatBox ("Saved ",source) 
            triggerServerEvent("savevehicle",getLocalPlayer(),code1) 
        elseif (player) then 
            local x, y, z = getElementPosition(getLocalPlayer()) 
            local code = x, y, z 
            triggerServerEvent("saveplayer",getLocalPlayer(),code) 
        end 
    end) 

And you didn't send upvalue you are using server side.

Link to comment

When the person press the check box it's suppose to get the player name and enter it to a Edit Box.

but when the player press it then the Text is not entered

Client-side:

  
-- The Checkbox 
GUIEditor_Checkbox[1] = guiCreateCheckBox(300,29,15,15,"",false,false,GUIEditor_Window[1])-- Nickname 
  
-- The function 
function clientNick1() 
    if guiCheckBoxSetSelected (GUIEditor_Checkbox[1], true) then 
        triggerServerEvent("clientUser1", getRootElement()) 
    else 
        cancelEvent() 
    end 
end 
  
addEvent("clientNick1",true) 
addEventHandler("clientNick1", getRootElement(), 
function(nameNick) 
    guiSetText(GUIEditor_Edit[1], nameNick) 
end) 
  

Server-side

  
  
-- Getting the Nickname 
addEvent("clientUser",true) 
addEventHandler("clientUser", getRootElement(), 
function() 
    local nick = getPlayerName(client) 
    triggerClientEvent("clientNick", getRootElement(), nick) 
end) 
addEvent("clientUser1",true) 
addEventHandler("clientUser1", getRootElement(), 
function() 
    local nameNick = getPlayerName(client) 
    triggerClientEvent("clientNick1", getRootElement(), nameNick) 
end) 
  

Link to comment
-- The Checkbox 
GUIEditor_Checkbox[1] = guiCreateCheckBox(300,29,15,15,"",false,false,GUIEditor_Window[1])-- Nickname 
  
function clientNick1() 
    if guiCheckBoxSetSelected (GUIEditor_Checkbox[1]) then 
         guiSetText(GUIEditor_Edit[1], getPlayerName(getLocalPlayer()) 
    end 
end 
addEventHandler("onClientGUIClick",GUIEditor_Checkbox[1],clickNick1,false) 

I don't understand why you have to trigger to the server if you only want to get client nick.

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