-
Posts
1,105 -
Joined
-
Last visited
Everything posted by Aibo
-
i dont know what problems you've had, MySQL and SQLite have pretty much the same syntax. that query you've wrote wouldn't work in MySQL either, as rememeber it. *) as for changing player-thePlayer, you probably missed something there
-
totally agree, i somehow missed that source isn't the "hidden" source
-
data fetched from the database is put into table "result" with the same key, so you'll have to access by it, like result[1].Geld also fix your query, you're trying to get a value from column "Kevin433", where the Geld equals undefined variable "usergeld" *) function SQLData(thePlayer) sourcename = getPlayerName ( thePlayer ) result = executeSQLQuery("SELECT Geld FROM Geld WHERE Player = '" .. sourcename .. "'") if #result > 0 then outputChatBox("Du hast " .. result[1].Geld .. "$", thePlayer) else -- nothing found in the database end end addCommandHandler("info", SQLData) (i dont know how you organized your Geld table, so i just put Player there, which is where you store the associated player's name or whatever)
-
yep, that should work, you dont need a global, you're just adding a key and a value to it.
-
use [ lua] tag for your code, it highlights the syntax/functions *) looks like you're passing undefined variables (like pLevel) as a key, try using quotes: gPlayerInfo[source]['pLevel'] = 1 or gPlayerInfo[source].pLevel = 1 and why create 1-100 indexed table (you probably not going to need it anyway), if your script uses player element as a key anyway? in Lua almost anything can be a table key. and defining the whole table for 100 players isnt needed really. i'd make it like this: gPlayerInfo = {} function joinHandler() gPlayerInfo[source] = {} gPlayerInfo[source].pSQLID = 1 gPlayerInfo[source].pAdmin = "some string value" gPlayerInfo[source].pLevel = 1 end -- eventuri addEventHandler("onPlayerJoin", getRootElement(), joinHandler) function DebugFunction(thePlayer) outputChatBox ( "Variabila are " .. gPlayerInfo[thePlayer].pLevel .. " valoarea ",thePlayer ) end -- comenzi addCommandHandler("debugf", DebugFunction) let pro-scripters correct me if im wrong *)
-
what's wrong with executeSQLQuery? result = executeSQLQuery("SELECT password FROM players WHERE player = '" .. getPlayerName(source) .. "'")
-
you forgot to get 'password' from database
-
1. you forgot to guiSetInputEnabled(false), fixed 2. dont store login/passwords in client files, its unsafe and uhm... just weird added a server event if player succesfully logged in. 3. your rules timer was starting when rules window was created, not shown, moved it to login event. server: function joinHandler() outputChatBox("--------------------", source) end addEventHandler("onPlayerJoin", getRootElement(), joinHandler) local time = getRealTime() setMinuteDuration(60000) setTime(time.hour, time.minute) -- create the function the command handler calls, with the arguments: thePlayer, command, vehicleModel function createVehicleForPlayer(thePlayer, command, vehicleModel) -- create a vehicle and stuff local x,y,z = getElementPosition(thePlayer) x = x + 5 -- ensures vehicle wont spawn in player -- create the vehicle and store the returned vehicle element in the ''createdVehicle'' variable local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z) if not createdVehicle then outputChatBox("Failed to create vehicle.",thePlayer) end end -- create a command handler addCommandHandler("createvehicle", createVehicleForPlayer) -- create our loginHandler function, with username and password parameters (passed from the client gui) 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 setCameraTarget(source, source) fadeCamera(source, false) outputChatBox("Thank you for logging in.", source) triggerClientEvent(source, "playerHasLoggedIn", source) else -- if the username or password are not correct, output message to player outputChatBox("Invalid username and/or password. Please try again.",source) end end addEvent("submitLogin",true) addEventHandler("submitLogin",root,loginHandler) function kickInactivePlayer() kickPlayer(client,"Please accept our rules.") end function moveThePlayer(x,y,z,rotation) if x and y and z and rotation then local skin = getElementModel(client) spawnPlayer(client,x,y,z,rotation,skin) setCameraTarget(client,client) end end addEvent("movePlayerToPosition",true) addEventHandler("movePlayerToPosition",root,moveThePlayer) addEvent("clientKickInactivePlayer",true) addEventHandler("clientKickInactivePlayer",root,kickInactivePlayer) client: local rulesWarningTimer = nil function createLoginWindow() -- define the X and Y positions of the window local X = 0.375 local Y = 0.375 -- define the width and height of the window local Width = 0.25 local Height = 0.25 -- create the window and save its element value into the variable 'wdwLogin' -- click on the function's name to read its documentation wdwLogin = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) -- define new X and Y positions for the first label X = 0.0825 Y = 0.2 -- define new Width and Height values for the first label Width = 0.25 Height = 0.25 -- create the first label, note the final argument passed is 'wdwLogin' meaning the window -- we created above is the parent of this label (so all the position and size values are now relative to the position of that window) guiCreateLabel(X, Y, Width, Height, "Username", true, wdwLogin) -- alter the Y value, so the second lebel is slightly below the first Y = 0.5 guiCreateLabel(X, Y, Width, Height, "Password", true, wdwLogin) X = 0.415 Y = 0.2 Width = 0.5 Height = 0.15 edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) Y = 0.5 edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) -- Max chars to 50 guiEditSetMaxLength(edtUser, 50) guiEditSetMaxLength(edtPass, 50) X = 0.415 Y = 0.7 Width = 0.25 Height = 0.2 btnLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) -- make the window invisible guiSetVisible(wdwLogin, false) -- stop players from being able to simply move the window out of the way guiWindowSetMovable(rulesWindow,false) -- stop players from being able to resize the window guiWindowSetSizable(rulesWindow,false) -- now add our onClientGUIClick event to the button we just created addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) end -- attach the event handler to the root element of the resource -- this means it will only trigger when ts own resource is started addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () -- create the log in window and its components createLoginWindow() -- output a bried welcome message tot he player outputChatBox("Welcome to DarkM's RP, please log in.") -- if the GUI was successfully created, the show the GUI to the player if (wdwLogin ~= nil) then guiSetVisible(wdwLogin, true) else -- if the GUI hasn't been properly created, tell the player outputChatBox("An unexpected error has occured and the log in GUI has not been created.") end -- enable the players cursor (so they can select and click on components) showCursor(true) -- set the input focus onto the GUI, allowing players (For example) to press 'T' without the chatbox opening guiSetInputEnabled(true) end ) -- create the function and define the 'button' and 'state' parameters -- (these are passed automatically by onClientGUIClick) function clientSubmitLogin(button,state) if button == "left" and state == "up" then -- get the text entered in the 'unsername' 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", getLocalPlayer(), username, password) else -- otherwise, output a message to the player, do not trigger the server -- and do not hide thr gui outputChatBox("Please enter a username and password.") end end end -- create the function that will hold our gui creation code function createRulesWindow() -- get the screen width and height local sWidth, sHeight = guiGetScreenSize() -- create the window, using some maths to find the centre of the screen local Width, Height = 445,445 local X = (sWidth/2) - (Width/2) local Y = (sHeight/2) - (Height/2) -- create the window rulesWindow = guiCreateWindow(X,Y,Width,Height,"Rules",false) -- stop players from being able to simply move the window out of the way guiWindowSetMovable(rulesWindow,false) -- stop players from being able to resize the window guiWindowSetSizable(rulesWindow,false) guiSetVisible(rulesWindow,false) -- create the button and save the button gui element in a variable called 'rulesButton' rulesButton = guiCreateButton(137,394,158,37,"Accept",false,rulesWindow) -- create the label and save the label gui element in a variable calle 'rulesLabel' -- we set the text odf the label to our rules rulesLabel = guiCreateLabel(10,25,425,359,[[ Welcome to DarkM's RP Please carefully read the rules before accepting. By accepting the rules, you are agreeing to play by them. Anyone caught breaking these rules will be kicked and/or banned from this server. If you do not accept the rules within 90 seconds, you will be kicked. 1: No cheating. 2: No bug abuse. 3: No vehicle handling mods or other beneficial mods. 4: RP at all times. This is a strict RP server, any non-RP is punishable.]],false,rulesWindow) -- set the horizontal alignment of the label to center (ie: in the middle of the window) -- also note the final argument "true" -- this turns on wordwrap so if your text goes over the edge of the label, it will wrap around and start a new line automatically guiLabelSetHorizontalAlign(rulesLabel,"center",true) addEventHandler("onClientGUIClick", rulesButton, acceptRules, false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () -- call the createRulesWindow function to create our gui createRulesWindow() -- show the cursor to the player showCursor(true,true) end ) function acceptRules(button,state) if button == "left" and state == "up" then guiSetVisible(rulesWindow, false) guiSetVisible(teleportWindow, true) showCursor(false,false) outputChatBox("Thank you for accepting the rules. Have fun RPing!") if rulesWarningTimer then killTimer(rulesWarningTimer) rulesWarningTimer = nil end end end function inactivePlayer(status) if status == 1 then outputChatBox("Please accept rules or else you will be kicked.") rulesWarningTimer = setTimer(inactivePlayer,30000,1,2) elseif status == 2 then triggerServerEvent("clientKickInactivePlayer",getLocalPlayer()) end end function createTeleportWindow() local sWidth, sHeight = guiGetScreenSize() local Width,Height = 231,188 local X = (sWidth/2) - (Width/2) local Y = (sHeight/2) - (Height/2) teleportWindow = guiCreateWindow(X,Y,Width,Height,"Starting Area",false) guiWindowSetSizable(teleportWindow,false) teleportLabel = guiCreateLabel(18,23,191,33,"Bus or Plane?",false,teleportWindow) guiLabelSetHorizontalAlign(teleportLabel,"center",true) teleportButtonBus = guiCreateButton(18,63,195,35,"Bus",false,teleportWindow) teleportButtonPlane = guiCreateButton(18,143,195,35,"Plane",false,teleportWindow) guiSetVisible(teleportWindow, false) addEventHandler("onClientGUIClick",teleportButtonBus,teleportPlayer,false) addEventHandler("onClientGUIClick",teleportButtonPlane,teleportPlayer,false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () createTeleportWindow() end ) function teleportPlayer(button,state) if button == "left" and state == "up" then if source == teleportButtonBus then triggerServerEvent("movePlayerToPosition",getLocalPlayer(),1743,-1863,14,0) outputChatBox("You have arrived to Los Santos from the bus. Happy RPing!") elseif source == teleportButtonPlane then triggerServerEvent("movePlayerToPosition",getLocalPlayer(),1686,-2239,14,0) outputChatBox("You have arrived to Los Santos from the plane. Happy RPing!") end guiSetVisible(teleportWindow, false) guiSetInputEnabled(false) showCursor(false) fadeCamera(true) end end addEvent("playerHasLoggedIn", true) addEventHandler("playerHasLoggedIn", getRootElement(), function() guiSetVisible(wdwLogin, false) guiSetVisible(rulesWindow,true) rulesWarningTimer = setTimer(inactivePlayer,30000,1,1) end )
-
use XML or SQL. btw why do you need your own authorization system if MTA package already has one?
-
when creating windows hide them with guiSetVisible(blabla, false) and then show/hide what you need. for example, adding this to accept button event will hide rulesWindow and show teleportWindow: guiSetVisible(rulesWindow, false) guiSetVisible(teleportWindow, true) its not that hard.
-
fixed some more typos, marked with -- FIX tested, it works. except your spawnpoint was buggy, so i made it a little higher and you probably better restore login window if login failed, not asking player to reconnect. but thats up to you client: function createLoginWindow() -- define the X and Y positions of the window local X = 0.375 local Y = 0.375 -- define the width and height of the window local Width = 0.25 local Height = 0.25 -- create the window and save its element value into the variable 'wdwLogin' -- click on the function's name to read its documentation wdwLogin = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) -- define new X and Y positions for the first label X = 0.0825 Y = 0.2 -- define new Width and Height values for the first label Width = 0.25 Height = 0.25 -- create the first label, note the final argument passed is 'wdwLogin' meaning the window -- we created above is the parent of this label (so all the position and size values are now relative to the position of that window) guiCreateLabel(X, Y, Width, Height, "Username", true, wdwLogin) -- alter the Y value, so the second lebel is slightly below the first Y = 0.5 guiCreateLabel(X, Y, Width, Height, "Password", true, wdwLogin) X = 0.415 Y = 0.2 Width = 0.5 Height = 0.15 edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) Y = 0.5 edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) -- Max chars to 50 guiEditSetMaxLength(edtUser, 50) guiEditSetMaxLength(edtPass, 50) X = 0.415 Y = 0.7 Width = 0.25 -- FIX: Wdith > Width Height = 0.2 btnLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) -- make the window invisible guiSetVisible(wdwLogin, false) -- now add our onClientGUIClick event to the button we just created addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) end -- attach the event handler to the root element of the resource -- this means it will only trigger when ts own resource is started addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () -- create the log in window and its components createLoginWindow() -- output a bried welcome message tot he player outputChatBox("Welcome to DarkM's RP, please log in.") -- if the GUI was successfully created, the show the GUI to the player if (wdwLogin ~= nil) then guiSetVisible(wdwLogin, true) else -- if the GUI hasn't been properly created, tell the player outputChatBox("An unexpected error has occured and the log in GUI has not been created.") end -- enable the players cursor (so they can select and click on components) showCursor(true) -- set the input focus onto the GUI, allowing players (For example) to press 'T' without the chatbox opening guiSetInputEnabled(true) end ) -- create the function and define the 'button' and 'state' parameters -- (these are passed automatically by onClientGUIClick) function clientSubmitLogin(button,state) if button == "left" and state == "up" then -- get the text entered in the 'unsername' field local username = guiGetText(edtUser) -- get the text entered in the 'password' field local password = guiGetText(edtPass) -- FIX: guiEditText > guiGetText -- 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", getLocalPlayer(), 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 thr gui outputChatBox("Please enter a username and password.") end end end server: function joinHandler() local x = 1743 local y = -1863 local z = 14 -- spawnPlayer(source, x, y, z) -- fadeCamera(source, true) outputChatBox("Welcome to DarkM's RP", source) end addEventHandler("onPlayerJoin", getRootElement(), joinHandler) -- create the function the command handler calls, with the arguments: thePlayer, command, vehicleModel function createVehicleForPlayer(thePlayer, command, vehicleModel) -- create a vehicle and stuff local x,y,z = getElementPosition(thePlayer) x = x + 5 -- ensures vehicle wont spawn in player -- create the vehicle and store the returned vehicle element in the ''createdVehicle'' variable local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z) if (createdVehicle == false) then -- FIX: createVehicle > createdVehicle outputChatBox("Failed to create vehicle.",thePlayer) end end -- create a command handler addCommandHandler("createvehicle", createVehicleForPlayer) -- create our loginHandler function, with username and password parameters (passed from the client gui) 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 spawnPlayer(source, 1959.55, -1714.46, 20) setCameraTarget(source, source) fadeCamera(source, true) outputChatBox("Welcome to DarkM's RP.", source) end else -- if the username or password are not correct, output message to player outputChatBox("Invalid username and/or password. Please re-connect and try again.",source) end end addEvent("submitLogin",true) addEventHandler("submitLogin",root,loginHandler)
-
and i didn't say that it'll fix all your problems for example, you have this in client script: local username = guiGetText(edtUser) local password = guiEditText(edtPass) what's guiEditText?
-
i'm pretty sure the souce of submitLogin must be getLocalPlayer(), not the root element: triggerServerEvent("submitLogin", getLocalPlayer(), username, password) and function loginHandler(username,password) if username == "user" and password == "apple" then if (source) then spawnPlayer(source, 1959.55, -1714.46, 10) fadeCamera(source, true) outputChatBox("Welcome to DarkM's RP.", source) end else outputChatBox("Invalid username and/or password. Please re-connect and try again.", source) end end
-
you haven't closed "if (money > 666) then" with "end" addEvent("fixVehicleRequest", true) addEventHandler("fixVehicleRequest", getRootElement(), function() if isPedInVehicle(source) then if (getPlayerMoney(source) > 666) then takePlayerMoney(source, 666) fixVehicle(getPedOccupiedVehicle(source)) outputChatBox("Vehicle Successfully Fixed", source, 255, 255, 0, true) else outputChatBox("Not enough money.", source, 255, 0, 0, true) end else outputChatBox("You are not in a vehicle", source, 255, 0, 0, true) end end )
-
and better use isPedInVehicle and getPedOccupiedVehicle why you need to bind "left" to it? is it a GUI button or what? anyway, your code is really a mix of client and server functions, here's the server part: addEvent("fixVehicleRequest", true) addEventHandler("fixVehicleRequest", getRootElement(), function() if isPedInVehicle(source) then fixVehicle(getPedOccupiedVehicle(source)) outputChatBox("Vehicle Successfully Fixed", source, 255, 255, 0, true) else outputChatBox("You are not in a vehicle", source, 255, 0, 0, true) end end ) you need to call this from the client. thru triggerServerEvent i guess: triggerServerEvent("fixVehicleRequest", getLocalPlayer())
-
needs more zombiegirls
-
one more thing. are you sure that everything is uploaded to the server with exact case (no "convert to lowercase" option or something)? i mean for linux server KIHC.lua and kihc.lua are different files. same with mta accounts, everything is case-sensitive.
-
hm, started the server with your acl/username, everything worked fine with KIHC that i have. the only thing i can think of is that you haven't reloaded ACL after editing it. if that's not the case - then i'm stuck
-
0.1.6 have different access right check on /buildhouse: if ( hasObjectPermissionTo ( player, "function.banIP" ) while 0.1.61 has login state check and this: if ( hasObjectPermissionTo ( name, "command.ban" ) ) so my bet is still same - messed up access rights. *) maybe you'll show your ACL?
-
i've spent some time with this resource today, adding house pickup change. if you want, you can get edited kihc here: https://forum.multitheftauto.com/viewtop ... 70#p302970 from what i can say, resource is fine (almost ), and worked fine for me. maybe you should double check your access rights?
-
as a proof for Jason_Gregory: addCommandHandler("marker", function () local x, y, z = getElementPosition(getLocalPlayer()) local groundz = getGroundPosition(x, y, z) createMarker(x, y, groundz, "cylinder", 2.0, 255, 255, 255, 255) end )
-
did you log in? cause it wont accept commands from guest accounts.
-
man, what's wont work for sure is this: local groundx, groundy, groundz getGroundPosition ( groundx, groundy, groundz+2 ) createMarker ( x, y, groundz , "cylinder", 2.0, 255, 255, 255, 255 ) groundx, groundy, groundz without values and getGroundPosition result goes nowhere. please, click on function name and read how getGroundPosition works: as for "omg its in the ground" - just add +2 or whatever, its not the reason for "it wont work dude".
-
i'm pretty sure getGroundPosition works this way: local groundz = getGroundPosition(x, y, z) createMarker(x, y, groundz, "cylinder", 2.0, 255, 255, 255, 255) and it's a client-only function.
