Jump to content

Corsaro Quad

Members
  • Posts

    23
  • Joined

  • Last visited

About Corsaro Quad

  • Birthday 01/03/1986

Details

  • Location
    Italy, EU
  • Interests
    Software engineering.

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Corsaro Quad's Achievements

Civilian

Civilian (7/54)

0

Reputation

  1. Thanks. It works. (spawn(source) is my personal function) But now it doesn't work the playSound... How can I resolve this?
  2. Hi. I've started to write the login GUI. I followed the tutorial on MTA wiki but there is a problem, in my mind, on triggering the server event. And I want to play a mp3 file when the player join into the server, but it doesn't work... This is the client code: function createLoginWindow() lblReportTxt = "Please LogIn." wdwLogin = guiCreateWindow(504,255,407,175,"Welcome!",false) lblReport = guiCreateLabel(15,27,70,16,lblReportTxt,false,wdwLogin) btnLogin = guiCreateButton(316,146,80,20,"LogIn",false,wdwLogin) lblUser = guiCreateLabel(85,62,61,17,"Username: ",false,wdwLogin) lblPass = guiCreateLabel(85,106,61,17,"Password:",false,wdwLogin) edtUser = guiCreateEdit(146,62,217,17,"",false,wdwLogin) guiEditSetMaxLength(edtUser,20) edtPass = guiCreateEdit(147,106,216,17,"",false,wdwLogin) guiEditSetMasked(edtPass,true) guiEditSetMaxLength(edtPass,20) -- make the window invisible guiSetVisible(wdwLogin, false) end addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () --getGamemodeVersion() welcomeSound = playSound("sounds/theme.mp3") setSoundVolume(welcomeSound, 0.5) -- create the log in window and its components createLoginWindow() -- output a brief welcome message to the player outputChatBox("Welcome to My MTA:SA Server, please log in.") -- if the GUI was successfully created, then show the GUI to the player if (wdwLogin ~= nil) then guiSetVisible(wdwLogin, true) else -- if the GUI hasnt been properly created, tell the player outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") end -- enable the players cursor (so they can select and click on the components) showCursor(true) -- set the input focus onto the GUI, allowing players (for example) to press 'T' without the chatbox opening guiSetInputEnabled(true) end ) function clientSubmitLogin(button,state) if button == "left" and state == "up" then -- get the text entered in the 'username' field local username = guiGetText(edtUser) -- get the text entered in the 'password' field local password = guiGetText(edtPass) -- if the username and password both exist if username and password then -- trigger the server event 'submitLogin' and pass the username and password to it triggerServerEvent("submitLogin", getRootElement(), username, password) -- hide the gui, hide the cursor and return control to the player guiSetInputEnabled(false) guiSetVisible(wdwLogin, false) showCursor(false) else -- otherwise, output a message to the player, do not trigger the server -- and do not hide the gui outputChatBox("Please enter a username and password.") end end end And this is the server code: function loginHandler(username,password) -- check that the username and password are correct if username == "user" and password == "apple" then -- the player has successfully logged in, so spawn them if (source) then spawn(source) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("Connected!", source) end else -- if the username or password are not correct, output a message to the player outputChatBox("Invalid username and password. Please re-connect and try again.",source) end end addEvent("submitLogin",true) addEventHandler("submitLogin",root,loginHandler) Thanks for your support.
  3. It works. Thanks. Update: It releases a space before the word... Is there a method to delete this space?
  4. Example: /do some actions Output on the Chat: some actions I think the gettok of value var take only the second word when I type the command. But I want to take and output infinite words after cmd value.
  5. Sorry for the double post but I have a problem with value var. In fact it reads only 1 token, but I want to read more tokens. Example: /do do some actions... It should outputs: * do some actions... I think to replace gettok to another function... This is the code: chat_range = 100 function onChat(player,_,...) cancelEvent() local x, y = getElementPosition(player) local circlearea = createColSphere ( x, y, 5, chat_range ) local msg = table.concat({...}, " ") local r,g,b = 255,255,255 local cmd = gettok(msg, 1, 32) local value = gettok(msg, 2, 32) playerName = getPlayerName(player) for i,v in ipairs(getElementsWithinColShape(circlearea, "player")) do if cmd ~= "" and cmd ~= nil then if cmd == "/do" and value ~= "" and value ~= nil then outputChatBox(value .. " (("..playerName.."))", v,r,g,b,true) else outputChatBox(playerName.." dice: #ffffff"..msg,v,r,g,b,true) end end end destroyElement ( circlearea ) end addCommandHandler("Chat",onChat) addEventHandler ( "onPlayerChat", getRootElement(), function (msg) onChat(source,_,msg) end)
  6. Ok. I try to recovery it... But a little question, can I set this script as a client-side script?
  7. Thanks man. It finally works! Thank you so much! /Solved Update: A little question, can I set this script as a Client-Side script?
  8. Thanks. I replaced it with createColCircle. Now it doesn't output the command or the simple message. How can I resolve it? (Remember: with isPlayerInRangeOfPoint it works fine!)
  9. It doesn't work... it doesn't output the command or the simple message and the server gives some errors: WARNING: Bad argument @ 'createColSphere' WARNING: Bad argument @ 'getElementsWithinColShape' ERROR: bad argument #1 to 'ipairs' (table expected, got boolean) WARNING: Bad argument @ 'createColSphere' WARNING: Bad argument @ 'getElementsWithinColShape' ERROR: bad argument #1 to 'ipairs' (table expected, got boolean)
  10. Fixed, but with isPlayerInRangeOfPoint. With isPlayerWithinColShape it doesn't work... Could you change from isPlayerInRangeOfPoint to isPlayerWithinColShape? Thanks. This is the code: --Code deleted.
  11. The normal chat not works but the command works fine. I replaced the isPlayerInRangeOfPoint with isPlayerWithinColShape and the server give me an error... Error: Bad argument @ 'isElementWithinColShape' Code: --Code deleted.
  12. Thanks man. Your explanation is very simple and the code now works fine. Thanks so much! EDIT: Oh... the server says the value var is a boolean value, but it outputs the text correctly... Server Error: "ERROR: resourcetest\localchat.lua:47: attempt to concatenate local 'value' (a boolean value)" This is the code: --Code deleted.
  13. Ok it works thanks. But now when I use a command with more arguments (example: /me blah blah blah or /pm Bob Yes I know! ) it doesn't work, it output normally the text. How can I resolve it? Thanks.
×
×
  • Create New...