Jaysds1 Posted July 4, 2011 Author Share Posted July 4, 2011 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
JR10 Posted July 4, 2011 Share Posted July 4, 2011 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
Jaysds1 Posted July 5, 2011 Author Share Posted July 5, 2011 There is something wrong with the removeEventHandler. Link to comment
Jaysds1 Posted July 5, 2011 Author Share Posted July 5, 2011 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
Jaysds1 Posted July 5, 2011 Author Share Posted July 5, 2011 yes, it's just the removeEventHandler, When I remove it, the images are shown but doesn't fadeout after 13 seconds. Link to comment
JR10 Posted July 5, 2011 Share Posted July 5, 2011 -- 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
Jaysds1 Posted July 5, 2011 Author Share Posted July 5, 2011 The image is not fading out after 13 seconds, the debugscript says Warning: Bad Argument @ 'removeEventHandler' Link to comment
Jaysds1 Posted July 6, 2011 Author Share Posted July 6, 2011 How to save Players Usernames and Passwords? Link to comment
JR10 Posted July 6, 2011 Share Posted July 6, 2011 Hmm?, what you mean save them username it's already saved, password you can setAccountData for it and it's already saved but hashed. Link to comment
Jaysds1 Posted July 6, 2011 Author Share Posted July 6, 2011 instead of the Player entering the username, the username is already in the gui Edited box. Link to comment
JR10 Posted July 6, 2011 Share Posted July 6, 2011 -- 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
Jaysds1 Posted July 7, 2011 Author Share Posted July 7, 2011 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
JR10 Posted July 7, 2011 Share Posted July 7, 2011 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
Jaysds1 Posted July 7, 2011 Author Share Posted July 7, 2011 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
Twisted Posted July 7, 2011 Share Posted July 7, 2011 Can't you do it by yourself instead of asking for help everyday? won't learn this way Link to comment
Castillo Posted July 7, 2011 Share Posted July 7, 2011 -- 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
Jaysds1 Posted July 8, 2011 Author Share Posted July 8, 2011 Sorry, I thought that the GetPlayerName was only Server-side, BWTwisted, I'll try doing that then!, And JR10, the script doesn't work but it's alright, i'll work on it myself... BYE ALL! (NO, I'M NOT SWITCHING TO SA:MP) Link to comment
Jaysds1 Posted July 10, 2011 Author Share Posted July 10, 2011 Can someone help me with this please: setTimer(removeEventHandler, 13000,0, "onClientRender", Function) Link to comment
Castillo Posted July 10, 2011 Share Posted July 10, 2011 Many ppl got this error, maybe is a bug, not sure, use this: setTimer(function () removeEventHandler("onClientRender",root,Function) end , 13000, 0) Try with that. Link to comment
Jaysds1 Posted July 10, 2011 Author Share Posted July 10, 2011 I tried that but the image or text doesn't show. Link to comment
Castillo Posted July 10, 2011 Share Posted July 10, 2011 That event is to REMOVE an event, not to add it. Link to comment
Jaysds1 Posted July 10, 2011 Author Share Posted July 10, 2011 I know, here: addEventHandler("onClientRender", root, Function) setTimer(function() removeEventHandler("onClientRender", root, Function),13000,0) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now