Jump to content

maky55

Members
  • Posts

    57
  • Joined

  • Last visited

Everything posted by maky55

  1. Thank you, I can't believe I didn't think to change the name of the command!
  2. Hello, scripting newb here! I'm trying to make a test script that output True or False depending if the user is on the specified account (2kjoe2k), here is the script: function getPlayerAccountName(playerSource, commandName) local accname = getAccountName(getPlayerAccount(playerSource)) if accname == "2kjoe2k" then outputChatBox("True") else outputChatBox("False") end end addCommandHandler("test", getPlayerAccountName) It's probably because I'm a newb but I can't get it to work. It doesn't post anything to chat and I get no errors with debugscript 3. Can anyone help? Thanks.
  3. Neves768 no work Instaid of saying no work, give us the problem that happens..
  4. Yeah thats what I'm trying to do. Ill try your script, thanks. Edit: I've tested the script, and it works just as I wanted to. It looks alot easier then I was trying to do. Thank you.
  5. Hello again. Thinking I might change my name to scripting newb. I'm pretty slow at this. Heres my problem, I want to make it so that if a player logs in and has a certain account name (terminator), he will spawn in SF airpot. But if he has a different account name (maky55) then he spawns at ls docks. Here are the 3 scripts I have: Server 1: local thePlayer = source function registerHandler(username, password) local account = getAccount ( username ) if ( not account ) then local register = addAccount(username, password) if ( register ) then outputChatBox("You have registered your account", source) end end end addEvent("submitRegister", true) addEventHandler("submitRegister", getRootElement(), registerHandler) function loginHandler(username, password) local account = getAccount(username, password) if ( account ) then local loggin = logIn(source, account, password) if ( loggin ) then triggerClientEvent(source, "hideLoginWindow", source) end else outputChatBox("Invalid username or password!",source) end end addEvent("submitLogin", true) addEventHandler("submitLogin", getRootElement(), loginHandler) Server 2: local posX1, posY1, posZ1 = 2584.9523925781, -2209.318359375, 1.9927320480347 local posX2, posY2, posZ2 = -1370.1851806641, -205.50845336914, 6 function joinHandler1() local account = getPlayerAccount(source) local accountName = getAccountName(account) if accountName == "maky55" then spawnPlayer(source, posX1, posY1, posZ1) fadeCamera(source, true) setCameraTarget(source, source) end addEventHandler("onPlayerLogin", getRootElement(), joinHandler1) end function joinHandler2() local account = getPlayerAccount(source) local accountName = getAccountName(account) if accountName == "terminator" then spawnPlayer(source, posX2, posY2, posZ2) fadeCamera(source, true) setCameraTarget(source, source) end addEventHandler("onPlayerLogin", getRootElement(), joinHandler2) end function deathHandler1() local account = getPlayerAccount(source) local accountName = getAccountName(account) if accountName == "maky55" then spawnPlayer(source, posX1, posY1, posZ1) fadeCamera(source, true) setCameraTarget(source, source) end addEventHandler("onPlayerWasted", getRootElement(), deathHandler1) end function deathHandler2() local account = getPlayerAccount(source) local accountName = getAccountName(account) if accountName == "terminator" then spawnPlayer(source, posX2, posY2, posZ2) fadeCamera(source, true) setCameraTarget(source, source) end addEventHandler("onPlayerWasted", getRootElement(), deathHandler2) end Client: local playerName = getPlayerName(localPlayer) local guiElements = { } function clientSubmitLogin() local username = guiGetText(guiElements["edit_user"]) local password = guiGetText(guiElements["edit_pass"]) if ( username ~= "" and password ~= "" ) then triggerServerEvent("submitLogin", localPlayer, username, password) else outputChatBox("Please enter a username and password.") end end function clientSubmitRegister() local username = guiGetText(guiElements["edit_user"]) local password = guiGetText(guiElements["edit_pass"]) if ( username ~= "" and password ~= "" ) then triggerServerEvent("submitRegister", localPlayer, username, password) else outputChatBox("Please enter a username and password to create an account.") end end function createLoginWindow() guiElements["login_window"] = guiCreateWindow(0.375, 0.375, 0.25, 0.25, "Please enter your Username and Password", true) guiCreateLabel(0.0825, 0.225, 0.25, 0.25, "Username", true, guiElements["login_window"]) guiCreateLabel(0.0825, 0.425, 0.25, 0.25, "Password", true, guiElements["login_window"]) guiElements["edit_user"] = guiCreateEdit(0.415, 0.2, 0.5, 0.15, "", true, guiElements["login_window"]) guiElements["edit_pass"] = guiCreateEdit(0.415, 0.4, 0.5, 0.15, "", true, guiElements["login_window"]) guiEditSetMasked ( guiElements["edit_pass"], true ) guiEditSetMaxLength(guiElements["edit_user"], 20) guiEditSetMaxLength(guiElements["edit_pass"], 20) guiElements["register_button"] = guiCreateButton(0.715, 0.7, 0.25, 0.20, "Register", true, guiElements["login_window"]) guiElements["login_button"] = guiCreateButton(0.415, 0.7, 0.25, 0.20, "Log In", true, guiElements["login_window"]) addEventHandler("onClientGUIClick", guiElements["login_button"], clientSubmitLogin, false) addEventHandler("onClientGUIClick", guiElements["register_button"], clientSubmitRegister, false) end addEventHandler("onClientResourceStart", resourceRoot, function () createLoginWindow() outputChatBox("Welcome to My MTA:SA Server, please log in.") showCursor(true) guiSetInputEnabled(true) end ) function hideLoginWindow() guiSetInputEnabled(false) showCursor(false) if ( isElement ( guiElements["login_window"] ) ) then destroyElement ( guiElements["login_window"] ) end end addEvent("hideLoginWindow", true) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) the second code is the one that is the most intrest. Instaid of spawning the player with the account name 'terminator' at SF airport and 'maky55' at the docks, it just stays on a black screen.
  6. maky55

    Spawn player.

    Thank you! I didn't know == meant exactly equal to! Thanks again.
  7. maky55

    Spawn player.

    Hello . I'm wondering whats wrong with this section of the script I have: local posX2, posY2, posZ2 = -1370.1851806641, -205.50845336914, 6 function joinHandler2() local account = getPlayerAccount(source) if account("Terminator") then spawnPlayer(source, posX2, posY2, posZ2) fadeCamera(source, true) setCameraTarget(source, source) end addEventHandler("onPlayerWasted", getRootElement(), joinHandler2) end I suspect i've got this line wrong: if account("Terminator") then I've tried many different ways of using this but I'm too newb . This is supposed to spawn the player at posX2, posY2, posZ2 (SF ariport) if their account is Terminator.
  8. The video is private. Instaid of private, put it as unlisted
  9. I don't think bfbfbf00 is a colour code. If you want gray try "7c7c7c" for a darker gray, "7e7979" for an average gray or "aeaeae" for a lighter gray (If we are talking about colour codes).
  10. maky55

    Null

    Hey guys! Well, today this isn't a broken script, it's a broken ACL . I started the server file as usual, and it was loading. Almost straight away, it came up with 'Error parsing the ACL (Access Control List) file. Or something like that and the server closed. I thought this was odd because I hadn't edited the ACL file. I decided to open it, and this is what I saw: nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull and it went on for quite a while. (the null text was surrounded by a black box) I then went to see the backups of the ACL, and they were all completly blank, and some even went up to a thousand lines long, with no text. I decided to open MTA server again, and it then said 'Couldn't parse meta file for resource "mods" '. In the metal file, it also came up with: nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull It hasen't happened since, every time I open MTA server, it just gives me the error of 'Couldn't parse meta file for resource "mods" '. and the same with acl. I can easily replace these files, but I was wondering if this was something to worry about? It's never happened to me before, and feels strange! Any help would be appreciated! Thanks, Tiger.
  11. Can I ask how you can delete accounts from the server? I created many when testing the script.
  12. Here is your problem, you are checking if the account already exists, then you add it, which makes no sense. Change these two lines to: local account = getAccount ( username ) if ( not account ) then Thank you at first, it didn't work, but I did some editing and got it to work!: At first, I did this: guiElements["register_button"] = guiCreateButton(0.715, 0.7, 0.25, 0.20, "Register", true, guiElements["login_window"]) guiElements["login_button"] = guiCreateButton(0.415, 0.7, 0.25, 0.20, "Log In", true, guiElements["login_window"]) addEventHandler("onClientGUIClick", guiElements["login_button"], clientSubmitLogin, false) addEventHandler("onClientGUIClick", guiElements["login_button"], clientSubmitRegister, false) then I realised I didn't change: guiElements["login_button"] But I changed it to guiElements["register_button"] and it worked . Thank you so much, you've helped alot! But, how do I delete accounts? I made like 20 testing the script?
  13. Well, the button came up with the word 'Register' on it, but it didn't register. What I added was probably wrong anyway. And the script was already ACL. And I'm getting no errors in debugscript 3
  14. That's wrong, the function name is outputChatBox Thanks for pointing that out for me , but that bit doesn't matter too much, cause it's the script that didn't work. I just need to know how to add a register button. Thanks anyway.
  15. Hey again . The newbie scripter here. Well this may seem real stupid thing to say, but I don't know how to add a register button to my login gui :\. I've looked all over for a register function on the wiki, and i have found: account addAccount ( string name, string pass ) I know it's a server side function, and i've tried messing about with the script to get it to register an account, but no luck here. Any help with this would be appreciated! Server: local posX, posY, posZ = 2584.9523925781, -2209.318359375, 1.9927320480347 local thePlayer = source function loginHandler(username, password) local account = getAccount(username, password) if ( account ) then local loggin = logIn(source, account, password) if ( loggin ) then spawnPlayer(source, posX, posY, posZ) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("Wow, you actually made it on", source) triggerClientEvent(source, "hideLoginWindow", source) end else outputChatBox("Invalid username or password!",source) end end addEvent("submitLogin", true) addEventHandler("submitLogin", getRootElement(), loginHandler) function deathHandler() spawnPlayer(source, posX, posY, posZ) fadeCamera(source, true) setCameraTarget(source, source) end addEventHandler("onPlayerWasted", getRootElement(), deathHandler) Client: local playerName = getPlayerName(localPlayer) local guiElements = { } function clientSubmitLogin() local username = guiGetText(guiElements["edit_user"]) local password = guiGetText(guiElements["edit_pass"]) if ( username ~= "" and password ~= "" ) then triggerServerEvent("submitLogin", localPlayer, username, password) else outputChatBox("Please enter a username and password.") end end function createLoginWindow() guiElements["login_window"] = guiCreateWindow(0.375, 0.375, 0.25, 0.25, "Please enter your Username and Password", true) guiCreateLabel(0.0825, 0.225, 0.25, 0.25, "Username", true, guiElements["login_window"]) guiCreateLabel(0.0825, 0.425, 0.25, 0.25, "Password", true, guiElements["login_window"]) guiElements["edit_user"] = guiCreateEdit(0.415, 0.2, 0.5, 0.15, "", true, guiElements["login_window"]) guiElements["edit_pass"] = guiCreateEdit(0.415, 0.4, 0.5, 0.15, "", true, guiElements["login_window"]) guiEditSetMaxLength(guiElements["edit_user"], 20) guiEditSetMaxLength(guiElements["edit_pass"], 20) guiElements["login_button"] = guiCreateButton(0.415, 0.7, 0.25, 0.20, "Log In", true, guiElements["login_window"]) addEventHandler("onClientGUIClick", guiElements["login_button"], clientSubmitLogin, false) end addEventHandler("onClientResourceStart", resourceRoot, function () createLoginWindow() outputChatBox("Welcome to My MTA:SA Server, please log in.") showCursor(true) guiSetInputEnabled(true) end ) function hideLoginWindow() guiSetInputEnabled(false) showCursor(false) if ( isElement ( guiElements["login_window"] ) ) then destroyElement ( guiElements["login_window"] ) end end addEvent("hideLoginWindow", true) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) Meta: <meta> <info author="Tiger" version="1.0" type="gamemode" name="Server" description="a simple spawn script" /> <script src="Server\Server_Script.lua" /> <script src="Client\gui.lua" type="client" /> </meta> Just for fun, here is what I tried to edit it too , atleast I tried : Server: local posX, posY, posZ = 2584.9523925781, -2209.318359375, 1.9927320480347 local thePlayer = source function registerHandler(username, password) local account = getAccount(username, password) if ( account ) then local register = addAccount(username, password) if ( register ) then outputChatbox("You have registered your account", source) end end end addEvent("submitRegister", true) addEventHandler("submitRegister", getRootElement(), registerHandler) function loginHandler(username, password) local account = getAccount(username, password) if ( account ) then local loggin = logIn(source, account, password) if ( loggin ) then spawnPlayer(source, posX, posY, posZ) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("Wow, you actually made it on", source) triggerClientEvent(source, "hideLoginWindow", source) end else outputChatBox("Invalid username or password!",source) end end addEvent("submitLogin", true) addEventHandler("submitLogin", getRootElement(), loginHandler) function deathHandler() spawnPlayer(source, posX, posY, posZ) fadeCamera(source, true) setCameraTarget(source, source) end addEventHandler("onPlayerWasted", getRootElement(), deathHandler) Client: local playerName = getPlayerName(localPlayer) local guiElements = { } function clientSubmitLogin() local username = guiGetText(guiElements["edit_user"]) local password = guiGetText(guiElements["edit_pass"]) if ( username ~= "" and password ~= "" ) then triggerServerEvent("submitLogin", localPlayer, username, password) else outputChatBox("Please enter a username and password.") end end function clientSubmitPassword() local username = guiGetText(guiElements["edit_user"]) local password = guiGetText(guiElements["edit_pass"]) if ( username ~= "" and password ~= "" ) then triggerServerEvent("submitRegister", localPlayer, username, password) else outputChatBox("Please enter a username and password to create an account.") end end function createLoginWindow() guiElements["login_window"] = guiCreateWindow(0.375, 0.375, 0.25, 0.25, "Please enter your Username and Password", true) guiCreateLabel(0.0825, 0.225, 0.25, 0.25, "Username", true, guiElements["login_window"]) guiCreateLabel(0.0825, 0.425, 0.25, 0.25, "Password", true, guiElements["login_window"]) guiElements["edit_user"] = guiCreateEdit(0.415, 0.2, 0.5, 0.15, "", true, guiElements["login_window"]) guiElements["edit_pass"] = guiCreateEdit(0.415, 0.4, 0.5, 0.15, "", true, guiElements["login_window"]) guiEditSetMaxLength(guiElements["edit_user"], 20) guiEditSetMaxLength(guiElements["edit_pass"], 20) guiElements["register_button"] = guiCreateButton(0.315, 0.7, 0.25, 0.20, "Register", true, guiElements["login_window"]) guiElements["login_button"] = guiCreateButton(0.415, 0.7, 0.25, 0.20, "Log In", true, guiElements["login_window"]) addEventHandler("onClientGUIClick", guiElements["login_button"], clientSubmitLogin, false) end addEventHandler("onClientResourceStart", resourceRoot, function () createLoginWindow() outputChatBox("Welcome to My MTA:SA Server, please log in.") showCursor(true) guiSetInputEnabled(true) end ) function hideLoginWindow() guiSetInputEnabled(false) showCursor(false) if ( isElement ( guiElements["login_window"] ) ) then destroyElement ( guiElements["login_window"] ) end end addEvent("hideLoginWindow", true) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) thanks, Tiger.
  16. Maybe it's not for download, and the person who made it doesn't want to release it to everyone. If so, you could try asking the sever who made the script to let you have it, but they'd probably say no. You could make your own, or try to find one https://community.multitheftauto.com/ Sorry if this isn't helpful . Tiger.
  17. If you look at his pictures this is what his script looks like: local spawnX, spawnY, spawnZ = 1959.9, -1714.46, 10 function joinHandler() spawnPlayer(source, spawnX, spawnY, spawnZ) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("Welcome to my server!", source) end addEventHandler("onPlayerJoin", getRootElement(), joinHandler) It shows that he did put fadeCamera into his script. Maybe you should pay more attention . Anyway, I'm basically a scripting newbie too, but I don't know if it'll cause problems that you have no spacing in your lines. Personally, i'd put the script like this: local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10 function joinHandler() spawnPlayer(source, spawnX, spawnY, spawnZ) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("Welcome to My Server", source) end addEventHandler("onPlayerJoin", getRootElement(), joinHandler) see how spawnPlayer is under function and the rest follow like that? I don't really know if not spacing it out will give you problems, but it could help.
  18. IT WORKKSSSSSSSSSSS!!!!!!!!!!!!!!!!!!!!!!!!!!! Omg dude thank you so much! You just saved me trying to write a new script.
  19. It shows: admin:password 1 2
  20. And also, this is a warning about it: WARNING:[gameplay]\server\server.lua:5: Bad argument @ 'logIn' [Expected account at argument 2, got string 'admin'] Ill check it now
  21. I've already added it. Problem is, it doesn't actually log me in, and the gui doesn't disapeer either. And also, this is a warning about it: WARNING:[gameplay]\server\server.lua:5: Bad argument @ 'logIn' [Expected account at argument 2, got string 'admin']
  22. Yeah it showed: admin:password admin:password
  23. Yes of course . Any help is appreciated.
×
×
  • Create New...