Jump to content

tosfera

Members
  • Posts

    1,193
  • Joined

  • Last visited

Everything posted by tosfera

  1. try to make it a "type='client'" @ the file element.
  2. You're actually still executing binds in the background, Viruz. You should make a check inside the onClientKey and see if the user is using your input. If it is, simply use cancelEvent and "return" to stop it from happening. The normal chatbox is bound to some keys and if you're using those without taking note of that, it'll start throwing random errors.
  3. tosfera

    SQL

    Make sure that the quotes are a backtick/grave ( ` ) and not a quote in your script. you might want to remove them.
  4. Something like that, yes. But you do need the marker model, go into the map editor and create a marker. it'll give you the model ID.
  5. I was about to say so ya, the thing about callRemote is that it's not posting data and the api requires a POST instead of a GET.
  6. [just letting you know that I'm currently trying to rewrite the PHP script towards Lua for you and give it a test here and there. Hang on ]
  7. That should prob. be a new animated object. Try to replace it with the bunch of EngineLoadTXD and that kind of stuff.
  8. below the; OnVehicleEnter = function ( player, seat, jacked ) add; if ( player == getLocalPlayer() ) then also make sure to end the if-statement after you're showing the buttons.
  9. tosfera

    SQL

    Try an approach like this; local connection; addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource() ), function() connection = dbConnect( "mysql", "dbname=mta;host=127.0.0.1", "mta", "***", "share=1" ); if ( connection ) then outputServerLog ( "MySQL connection has been established." ); else outputServerLog ( "Couldn't connect to the MySQL server." ); end end ); function dbSelect ( query ) if ( connection ) then local tmpQuery = dbQuery ( connection, tostring ( query ) ); return dbPoll ( tmpQuery, -1 ); end return false; end function dbInsert ( query ) if ( connection ) then dbQuery ( connection, tostring ( query ) ); end end addEventHandler ( "onPlayerJoin", getRootElement(), function () local playerNick = getPlayerName ( source ); local isValidPlayer = dbSelect ( "SELECT `user_id` FROM `user` WHERE `user_name` = '".. playerNick .."'" ); if ( isValidPlayer and isValidPlayer [ 0 ] ~= nil ) then if ( isValidPlayer [ 0 ].user_password ~= "" ) then -- log in the user if he fills in a password or what so ever. else -- not a valid user end else dbInsert ( "INSERT INTO `user` ( `user_name`, `user_level`, `user_password`, `user_ip` ) VALUES ( '".. playerNick .."', 1, '', '".. getPlayerIP ( source ) .."' )" ); end end ); note: I never use this way of handling a database. I always go for the outdated mysql plugin.
  10. tosfera

    SQL

    queryDb("INSERT INTO user ('user_name') VALUES ('"..playerNick.."')") queryDb("INSERT INTO user ('user_ip') VALUES ('"..playerIP.."') WHERE user_name='"..playerNick.."'") Those will fail, you're not allowed to insert NULL values into every field. So if you want to insert them all, make 1 query out of it: queryDb ( "INSERT INTO `user` ( `user_level`, `user_name`, `user_password`, `user_ip` ) values ( 1, ?, '', ? )", playerNick, playerIP )
  11. Your source in your outputChatBox equals to something else instead of a player.
  12. First assign an ID to them, after that you can try to use bindKey to bind your key, createColSphere to create a small sphere once a player hits the button. After that use getElementsWithinColShape to get the vehicles around him/her. If there are vehicles in his area, check the elementData to see if the vehicle is owned by him or locked ( not sure how you want to protect it ) and get the closest vehicle too. Once you've done that, get the elementBoundingBox and see if the user is at the end of the vehicle ( get the distance from the biggest value from the vehicle and the position from the player ). Then open it.
  13. tosfera

    SQL

    That's even easier, go to the "TABLES" place and scroll to the bottom and click; create new table. Fill in the amount of columns and the name. Each column should use the "NOT NULL" thing ( don't check the NULL box ) and check the AI for the id. Besides that, fill in the datatypes, field names and the length. Since you're speaking Dutch, you don't need any explanation for the image; full res on; http://puu.sh/mLxMz/a9288c6bd0.png ( left the length of values out for id, level and banned since the default length for int goes to 11. Quite too much for a level and banned. Level can be 3 ( goes up to 999 ) and banned can be 1 ( from 0 to 9 ) ).
  14. When the vehicle spawns, use setElementData to set the data on the vehicle. From there request the data with getElementData every time you need it. Once the vehicle gets destroyed, make sure to save the new value in the database again.
  15. tosfera

    SQL

    The length, that's basically it. Creating an advanced table would require a bit more knowledge like; not null, datatypes, relations and shit. But as long as you validate your script good enough, you don't need all that bullcr*p. Creating a table is quite easy; CREATE TABLE `users` ( `id` int NOT NULL AUTO_INCREMENT, `username` varchar(45) NOT_NULL, `password` text ) That'll create the automatical increment for ids too.
  16. The lagging part is because it's trying to render an element each frame and it returns an error. That comes up to fps * error for each second. If you're running at 60 fps normally, it'll try to output 60 errors a second and lag your ass so hard that you're forced to stop the resource or close the window. The fact that the font has been returned as false gives you some shady information. You're getting a false which tells us that either the file couldn't be loaded or there were some wrong parameters. Let's go over everything you've done in the code. local myFont = dxCreateFont ( "Font.ttf", 2 ) You're using Font.ttf as a file, is it in the meta.xml? is the filename also a capital F? are you sure you want to have it as 2 in font size. That's 2 pixels.. something for ants. outputChatBox ( tostring ( myFont ) ) This returned false, try to add a try-catch on a dirty way by doing this; local myFont = dxCreateFont ( "Font.ttf", 2 ) if ( not myFont ) then myFont = dxCreateFont ( "Font.ttf", 2 ) end If that doesn't work, there might be something wrong with the memory free for MTA. Use DxGetStatus to see if you have any value in VideoMemoryFreeForMTA. If this returns false or 0, you're not going to get this to work. To built that into your entire system, you can add an if-statement like this; local myFont = nil; if ( dxGetStatus().VideoMemoryFreeForMTA > 0 ) then myFont = dxCreateFont ( "Font.ttf", 2 ); if ( not myFont ) then myFont = dxCreateFont ( "Font.ttf", 2 ); if ( not myFont ) then myFont = "default"; end end else myFont = "default"; end
  17. No, there is not. They once tried to do it but they couldn't reset the ped's animation back to the normal state so the user could walk again. Therefore they've removed it from the current releases and stopped working on it for now.
  18. Oh, well you still have to do the same and see if you can use SetCameraShakeLevel to disable that shaking, I'm not sure to be honest. The flying away.. you might want to stop the explosion with cancelEvent and create the explosion in the client side to stop the effects.
  19. Camera shaking, of course. Once the explosion takes place, create a colsphere by using createColSphere and get all the elements inside of it by using getElementsWithinColShape. Loop over them and run a function for those players.
  20. Sadly enough, you can't just randomly parse your parameters in your eventHandler, this has to be done with the function call itself. However, since you do want that vehicle to be in that function.. you can try to actually gather the data which you've already set in the marker's hit and see if there is an actual vehicle linked to that. function bindFunc ( hitElement ) if ( getElementType ( hitElement ) == "player" ) then local linkedVehicle = getElementData ( source, "marker" ); if ( isElement ( linkedVehicle ) ) then toggleControl ( hitElement, "enter_exit", false ); bindKey ( hitElement, "f", "down", funcName ); end end end setTimer ( function () for index, vehicle in pairs ( getElementsByType ( "vehicle" ) ) do if not ( getElementData ( vehicle, "marker" ) ) then local x, y, z = getElementPosition ( vehicle ); local vehMarker = createMarker ( x, y, z, "cylinder", 2.0, 255, 0, 0, 255 ); attachElements ( vehMarker, vehicle, 0, -3, -1 ); setElementData ( vehicle, "marker", vehMarker ); addEventHandler ( "onMarkerHit", vehMarker, bindFunc ); end end end, 6000, 0 ); Another thing that I would strongly suggest is keeping some kind of ID running on your vehicles so it's easier to obtain a vehicle as an element. By doing that you only have to save the vehicleId on the marker his butt and obtain the linked vehicle to it. If a vehicle currently explodes, the marker is still there. I do wonder, what are you trying to do? Maybe there is another way that could solve your problem.
  21. That's basic SQL knowledge; CREATE TABLE table_name ( column_name1 data_type(size), column_name2 data_type(size), column_name3 data_type(size), ); as stated here on the w3schools site; http://www.w3schools.com/sql/sql_create_table.asp
  22. That'll be really hard, I would suggest you to use either an SQL system or move over to an XML system to store information. Doing it this way requires a lot of string.find, string.sub and string.gsub..
  23. tosfera

    Solved

    That'll create the log on the server's filesystem and I think he wants to make them available for the client. Else I have no clue why he would've done it client-sided.
×
×
  • Create New...