-
Posts
23 -
Joined
-
Last visited
Everything posted by Corsaro Quad
-
EDIT: Solved!
-
Thanks. It works. (spawn(source) is my personal function) But now it doesn't work the playSound... How can I resolve this?
-
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.
-
It works. Thanks. Update: It releases a space before the word... Is there a method to delete this space?
-
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.
-
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)
-
Oh, ok. Thank you.
-
Ok. I try to recovery it... But a little question, can I set this script as a client-side script?
-
Thanks man. It finally works! Thank you so much! /Solved Update: A little question, can I set this script as a Client-Side script?
-
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!)
-
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)
-
Fixed, but with isPlayerInRangeOfPoint. With isPlayerWithinColShape it doesn't work... Could you change from isPlayerInRangeOfPoint to isPlayerWithinColShape? Thanks. This is the code: --Code deleted.
-
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.
-
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.
-
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.
-
Can you give me an example of the correct usage of string.sub, please? And, if you want, an example of isElementWithinColshape because I didn't find in the wiki and I don't know how it works. Thanks.
-
Hi. I'm doing a local chat but I can't use commands because when I type "/vehiclespawn" or "/login", it says normally "/vehiclespawn" and "/login" without execute the command. How can I resolve this? This is the code of the local chat script: -- Code deleted. Thanks for you support!
-
Thanks it works.
-
Ok, it works. It's nice and very simple. Great work! EDIT: I've scripted a login form with my UI created by this resource, but I have some issues. In fact it appears a damaged UI with no buttons and no labels... This is the code: function welcomeForm() initScreen = guiCreateWindow(101,55,1123,631,"",false) initScreen_Label[1] = guiCreateLabel(108,12,875,45,"Corsair Roleplay Project - Welcome to our server!",false,initScreen) guiLabelSetColor(initScreen_Label[1],150, 150, 170) guiSetFont(initScreen_Label[1],"sa-header") initScreen_Label[2] = guiCreateLabel(504,142,127,22,"work in progress...",false,initScreen) guiLabelSetColor(initScreen_Label[2],255, 15, 15) guiSetFont(initScreen_Label[2],"clear-normal") initScreenSplash = guiCreateGridList(26,174,1072,389,false,initScreen) guiGridListSetSelectionMode(initScreenSplash,2) initScreen_Label[4] = guiCreateLabel(40,44,66,18,"Username",false,initScreenSplash) guiSetFont(initScreen_Label[4],"clear-normal") initScreen_LoginForm_usernameInput = guiCreateEdit(116,38,285,33,"",false,initScreenSplash) guiEditSetMaxLength(initScreen_LoginForm_usernameInput, 50) initScreen_Label[5] = guiCreateLabel(40,108,66,18,"Password",false,initScreenSplash) guiSetFont(initScreen_Label[5],"clear-normal") initScreen_LoginForm_passwordInput = guiCreateEdit(116,99,285,33,"",false,initScreenSplash) guiEditSetMaxLength(initScreen_LoginForm_passwordInput, 50) initScreen_Label[3] = guiCreateLabel(8,573,1115,18,"______________________________________________________________________________________________________________________________________________________________",false,initScreen) guiSetAlpha(initScreen_Label[3],1) guiLabelSetColor(initScreen_Label[3],100, 150, 255) guiSetFont(initScreen_Label[3],"clear-normal") initScreen_LoginButton = guiCreateButton(1010,594,88,27,"Login",false,initScreen) guiSetVisible(initScreen, false) end addEventHandler("onClientGUIClick", initScreen_LoginButton, clientSubmitLogin, false) addEventHandler("onClientResourceStart",resourceRoot, function() welcomeForm() if (initScreen ~= nil) then guiSetVisible(initScreen, true) else outputChatBox("Error on creating the GUI.") outputConsole("Error on creating the GUI.") end showCursor(true) guiSetInputEnabled(true) end ) And this is the result: http://i39.tinypic.com/zn7vwy.png
-
[Outdated] Unofficial MTA Script Editor 0.3 (4851) RELEASED!
Corsaro Quad replied to 50p's topic in Scripting
OK, it works. Thank you! -
[Outdated] Unofficial MTA Script Editor 0.3 (4851) RELEASED!
Corsaro Quad replied to 50p's topic in Scripting
It's OK, but now when I try to load/make a new resource, it stops working... I used the last patch with the patcher. -
[Outdated] Unofficial MTA Script Editor 0.3 (4851) RELEASED!
Corsaro Quad replied to 50p's topic in Scripting
Hi. I've installed this application on my SD Card but when I try to start it, it says "MTA Server resources folder can not be found. Make sure you have installed... bla bla bla..". Can anyone help me? Thanks for your support. -
I have an issue when I run this resource. The server says me it's an invalid gamemode. Anyone can help me? Thanks.