3aGl3
Members-
Posts
128 -
Joined
-
Last visited
Everything posted by 3aGl3
-
So, your login function looks super wrong to me, first of all the variables handed to the function are local variables, so local username = arg1 etc. is totally unnecessary. Secondly, when handling sensitive data like a usernames and passwords you should always take proper security measures. At this point I'm afraid of creating an account on any MTA server with a password other than 12345...it seems noone takes security serious. Saving usernames and passwords is no joke, if your database is hacked the hacker has all the players usernames and passwords as clear text. Many people use one password for pretty much everything, while that isn't something you can change you can at least try to put a little effort into securing your players data. A proper way to do this looks something like this: --[[ - Attempts to log the player into the given account - - @param <string> username: Username for the account - @param <string> password: Password for the account ]] function requestPlayerLogin( username, password ) if not username or not password or username == "" or password == "" then outputDebugString( "Function requestPlayerLogin called without an username or password.", 2 ) return end -- get the account from the database local result = databaseQuery( "account", "SELECT `account_id`, `name`, `password`, `online` FROM `accounts` WHERE `name`=?", username ) if result then -- grab the account data from the query result local account = result[1] -- get the salt from the password field and hash the password send by the client local salt = string.sub( account.password, 65 ) password = sha256( salt..password ) -- check if the hash and the database hash match if password == string.sub( account.password, 1, 64 ) then -- check the online state of the account if account.online == 1 then -- let the player know that his account is already logged in outputChatBox( string.format( loc(client, "your_account_is_already_logged_in"), get("website") ), client, 255, 128, 128 ) return else -- set the accounts online flag result = databaseQuery( "account", "UPDATE `accounts` SET `online`=1, `last_online`=CURRENT_TIMESTAMP WHERE (`account_id`='?')", account.account_id ) if result then outputDebugString( "Successfully logged player ".. getPlayerName(client) .." in." ) -- save the players account id playerAccount[client] = account.account_id playerAccountName[client] = account.name -- trigger the server and client login event triggerEvent( "onPlayerSQLLogin", resourceRoot, client, account_id ) triggerClientEvent( client, "onClientPlayerLogin", resourceRoot ) -- log a successfull login databaseQuery( "account", "INSERT INTO `accountlogins` (`account`, `address`, `serial`, `success`) VALUES (?,?,?,?)", account.account_id, getPlayerIP(client), getPlayerSerial(client), 1 ) return end end end -- log a failed login attempt databaseQuery( "account", "INSERT INTO `accountlogins` (`account`, `address`, `serial`, `success`) VALUES (?,?,?,?)", account.account_id, getPlayerIP(client), getPlayerSerial(client), 0 ) end -- if we reach this the login request failed -- NOTE -- We stick to a generic error message, even though this isn't super user friendly -- this prevents a hacker from finding out valid usernames by trying to log into them. outputChatBox( loc(client, "invalid_username_or_password"), client, 255, 128, 128 ) end --[[ requestPlayerLogin ]] Note that I'm saving passwords as a salted hash and also log any attempt to log into an account. The databaseQuery function is pretty much just a dbQuery and dbPoll packed together with some other small things.
-
A link to where you got the gamemode is probably what he wants so he can check it out to better help you.
-
I looks pretty ok to me, however you should use triggerLatentClientEvent( client,] "recriveRss", 50000, false, resourceRoot, ss ) And probably triggerLatentServerEvent for requesting the entire process. On the other hand I have no idea what you are trying to achieve with this, you could just show the image directly, without sending it to the server...
-
I don't think setting all sync intervals that low is a good idea if you are expecting more than a few players. It might not be notable with 2 players but it sure will be with more... Not to mention that 10 seems a little low, even the player sync is only 100 by default.
-
Don't think there is a native function for that but this is how I'd do it: function getLongestString( table ) local longest for k, v in pairs( table ) do if not longest or string.len(v) > string.len(longest) then longest = v end end return longest end
-
This is what you are looking for: function drawImageBox( x, y, w, h ) -- you should probably check here for valid size etc. -- w and h need to be at least 32, 48 would probably be even better dxDrawImage( x, y, 16, 16, "images/left-up.png" ) dxDrawImage( x+16, y, w-32, 16, "images/up.png" ) dxDrawImage( x+w-16,y, 16, 16, "images/right-up.png" ) dxDrawImage( x, y+16, 16, h-32, "images/left.png" ) dxDrawImage( x+16, y+16, w-32, h-32, "images/center.png" ) dxDrawImage( x+w-16,y+16, 16, h-32, "images/right.png" ) dxDrawImage( x, y+h-16, 16, 16, "images/left-down.png" ) dxDrawImage( x+16, y+h-16, w-32, 16, "images/down.png" ) dxDrawImage( x+w-16,y+h-16, 16, 16, "images/right-down.png" ) end
-
Trailers are handled as empty vehicles in MTA and are only updated according to unoccupied_vehicle_sync_interval. That causes problems for all other players who see you pull that trailer, while for you it seems fine other players see the trailers correct position only every x ms. One fix would be to change the unoccupied_vehicle_sync_interval setting to a lower value but that will cause heavy server load. There is also a bug on the bugtracker but I can't find it.
-
It seems your model is invalid, try to open it in dff viewer or similar. The MTA server will also notify you about broken dff files, however that isn't always 100% accurate, I'm using a couple dffs that MTA reports as broken.
-
If I understand you correctly you want to kick a player without a serial, so that would be: function checkConnectingSerial( nick, ip, serial, iVersion, sVersion ) if not serial or string.len( serial ) ~= 32 then cancelEvent( true, "Invalid serial number." ) end end addEventHandler( "onPlayerConnect", root, checkConnectingSerial )
-
The code looks like it's ok, however this should be enough. txd = engineLoadTXD("hockey.txd") engineImportTXD(txd, 30376) dff = engineLoadDFF("hockeymask.dff") engineReplaceModel(dff, 30376) If you want any further help please post any error you get etc. I'm also not sure about the names but I personally never used different names for the txd and dff.
-
You probably want to check the input before doing anything, so move the if from line 4 up to line 2. Then in line 4 you should check if otherPlayer is not false...so something like this. function payScript(player,cmd,other,amount) if not other or not amount then outputChatBox( "#00BAFF[Play] #FFffFFHelyes használat: #0088FF/pay <név> <összeg>!", player, 0, 255, 255, true ) else local money = getPlayerMoney(player) local otherPlayer = getPlayerFromName(other) if otherPlayer then if (money - amount) < 0 then outputChatBox("#00BAFF[Play] #FFffFFNincs elegendo #0088FFpénzed!",player,0,255,255, true) else setPlayerMoney( otherPlayer, getPlayerMoney(otherPlayer) + amount ) outputChatBox( "#00BAFF[Play] #FFffFFKaptál #0088FF"..amount.."Ft-ot #FFffFFtole: #0088FF".. getPlayerName(player).."!",otherPlayer,0,255,255,true ) setPlayerMoney( player, money - amount ) outputChatBox( "#00bAFF[Play] #0088FF"..amount.."Ft-ot #FFffFFküldtél neki: #0088FF"..other.."!",player,0,255,255, true ) end else outputChatBox( "Could not find player ".. other, player, 0, 255, 255, true ) end end end addCommandHandler( "pay", payScript )
-
I see, on local entities the sync variable is overwritten anyway.
-
Thanks for the info, I somehow didn't think about the synced flag... Also I do know how variable scope, or in this case element data scope works, still, thanks.
-
Could it be the player isn't in a vehicle? You should do something like local vehicle = getPedOccupiedVehicle( hitPlayer ) if vehicle then local id = getVehicleID( vehicle ) ... end
-
I assume this is what you want, it'll create a new marker each time you use the pmr command. local pathMarkers = {} function pathMarker( thePlayer ) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then x, y, z = getElementPosition ( thePlayer ) local path = createMarker ( x, y-2, z+1, "arrow", 1.3, 0, 60, 255 ) setElementDimension ( path, 336 ) setElementInterior ( path, 0 ) pathMarkers[#pathMarkers+1] = path outputChatBox ( "Path Marker Created", thePlayer, 60, 255, 60, true ) else outputChatBox ( "Error", thePlayer, 200, 10, 10, true ) end end addCommandHandler( "pmr", pathMarker )
-
So I have a quick question regarding the setElementData function. While the wiki states that it can cause quite a bit of load on the net and server CPU I assume that this is only the case for server elements... What happens if I use setElementData on something that exists only on a client? Say a gui element or any kind of element that has been created on a client. Is the data still synced with the other clients or is it kept to the client the element exists on? 3aGl3
-
Create a blip like this: local north = createBlip( 0, 10000, 0, 4 ) If you already have a working custom radar it should just draw the blip like any other.
-
Good job Does it work in ints?
-
So, I tried the querying a SQLite database and can't seem to find any mistake here... For ease of use I did however use Navicat and not MTA, all queries worked just fine. However the positiondata should in theory be REAL and not INTEGER...SQLite did not complain and even saved the reals in the integer fields. Maybe MTA is picky there...
-
I haven't really worked with SQLite as I think it's not really more than an excel sheet compared to MySQL but as SQL is usually the same... There are only two small things I can see, first you never really use the plr variable but instead the source variable, second I always embed column and table names in ``, e.g. UPDATE `characters` SET `pos_y`='1' WHERE (`character_id`='2') Also I use Navicat Lite to double check my queries for function, might help you.
-
Can you post the entire function? There are clearly parts missing... Also please use the code function next time you post code to the forum.
-
Can you maybe post the error log?
-
First of all MySQL is build to handle such data quantities. Unless you get into the range of big data there shouldn't be a problem...now before you ask, big data is usually something like googles meta data on users or similar. (Billions, if not trillions of records) So given that your server will likely never exceed say 50,000 accounts, you may have a table with items or something else that has 5,000,000 records etc. however none of that is even remotely big enough to bring MySQL down...given that you use good keys and queries. However, you could of course still mess up. Trying to SELECT query the entire items table (5,000,000) items for whatever reason would be a bad idea for example but that's what the LIMIT argument is for. If you build a database for a gamemode you should definitely use a tool like MySQL Workbench. Like that you have a great overview on your tables and can even track the performance of your database server. (There is a free Community edition btw.) Also as pa3ck wrote, it's probably a good idea to cache certain things in lua tables, for example the locations of houses or similar won't usually change, so loading them when the resource starts is probably a good idea. If they really change, probably an admin placing new houses or so, save as soon as the change is done, that will leave you with little to save when the server shuts down. Now I don't (yet) have experience with a MTA server actually running on MySQL and having lots of data, however I worked with other games that had a MySQL database and it worked great, even with almost 1,000,000,000 entries in the items table.