-
Posts
226 -
Joined
-
Last visited
Everything posted by Maurize
-
Ryancit2, this is a good solution. I could insert all timers in table, make a for slope aand kill every timer! Thanks for giving me that idea
-
I know your code is right but that is not the point. The point is, that I need to kill these timers in a new function... addEvent( "onPedIntro1", true ) addEventHandler( "onPedIntro1", player, function( ped ) gangster_timer = setTimer( function() if ( ped ) then setPedAnalogControlState( ped, "special_control_left", math.random( 0, 1 ) ); setPedAnalogControlState( ped, "special_control_right", math.random( 0, 1 ) ); setPedAnalogControlState( ped, "special_control_down", math.random( 0, 1 ) ); setPedAnalogControlState( ped, "special_control_up", math.random( 0, 1 ) ); end end, math.random( 500, 900 ), 0 ) end ) addEvent( "onPedIntro2", true ) addEventHandler( "onPedIntro2", player, function( ped ) police_timer = setTimer( function() if ( ped ) then local pX, pY, pZ = getPedBonePosition( player, math.random( 1, 54 ) ); setPedControlState( ped, "fire", true ); setPedAimTarget( ped, pX, pY, pZ ); end end, math.random( 500, 1000 ), 0 ) end ) addEvent( "...", true ) addEventHandler( "...", player, function() killTimer( xy ) -- doesnt work, gives error. expected element/timer at line xy end) SECOND is, that I need to check if 1 hour is reached... Players time is stored in element data by seconds. Now I have to check if a hour is passed ( because payday and stuff ). Any ideas? addEventHandler( "onClientResourceStart", resourceRoot, function() setTimer( function() if ( getElementData( element, "time" ) / 3600 == 1 ) then -- yeah, 1 hour is passed but how to get next? triggerServerEvent( "onPlayerTax", element ); end, 1000, 0 ) end )
-
This isn't possible. For example: Function got triggered by Server and starts a timer. Timer is working. 1 Minute later I need to kill Timer.
-
Hello everybody, I have following problem: When I use a timer clientside in a function, how is it possible to delete it out of another function? I'm trying any way I know but nothing seems to work... Thanks.
-
and this way? function setSQLData( element, row, data ) local db = executeSQLQuery( "SELECT * FROM ? WHERE name = ?", "db", getPlayerName( element ) ) if ( db and #db == 1 ) then executeSQLQuery( "UPDATE db SET '"..row.."' = '"..data.."' WHERE name = '"..getPlayerName( element ).."'", "db", getPlayerName( element ) ) else executeSQLQuery( "INSERT INTO db( '"..row.."' ) VALUES( '"..data.."' )", "db", getPlayerName( element ) ) end end
-
Maybe this is a good information for you: https://wiki.multitheftauto.com/wiki/Meta.xml Otherwise the easiest way that I know is, to set a value in xml and modify it through script.
-
Huh I don't understand? I mean your gui has to be visible get position. Buuuuuut there is a work around. GuiSetAlpha OnClientMouseEnter OnClientMouseLeave
-
You can enter every Place, for example in Map Editor.
-
Hey, I'm working on my SQL Functions... So, my question is, if it's possible to make something like this: function setSQLData( element, row, data ) local db = executeSQLQuery( "SELECT * FROM ? WHERE name = ?", "db", getPlayerName( element ) ) if ( db and #db == 1 ) then executeSQLUpdate( "db", row.." = '"..data.."'", "name = '"..getPlayerName( element ).."'" ) else executeSQLQuery( "INSERT INTO db( '..row..' ) VALUES( '..data..' ) WHERE name = '"..getPlayerName( element ).."'" ) end end So functions requests if data is already there and if not the data gets insert so I don't have to make a single large insert execute...
-
If I call newSQLData() it prints both options to console and insert. So it ignores the check if the user is already in database? What is wrong... ? EDIT: If table isn't present, it doesn't create it at first time. But if I restart the project, table gets created... [code=text]function setSQLData( row, value ) db:exec( "UPDATE db SET '"..row.."' ='"..value.."', WHERE name = 'user'" ) end function getSQLData( row ) local value = db:exec( "SELECT '"..row.."' FROM db WHERE name = 'user'" ) if ( value ) then return value else return false end end function newSQLData() if ( getSQLData( "name" ) ~= "user" ) then db:exec( "INSERT INTO db( name, audio, score ) VALUES( 'user', 'on', '0' )" ) print( "newSQLData() called INSERT" ) else return false end print( "newSQLData() called FALSE" ) end [/code]
-
yeah Maybe. anyway thanks alot
-
nope, seems like the column rowid isn't present.. // found solution for my own. addCommandHandler( "call", function( player, cmd ) local db = executeSQLQuery( "SELECT rowid, * FROM db_data", player ) outputChatBox( "Das Ziel trägt die ID: "..db[1]["rowid"], player, 255, 255, 0 ) end )
-
Data gets saved via getSQLData Function so it does work with values in table...
-
of course it is. executeSQLQuery( "CREATE TABLE IF NOT EXISTS db_data( id INT IDENTITY( 1,1 ) PRIMARY KEY, name STRING, code STRING, life INT, armor INT, skin INT, meele INT, gun INT, ammo INT, pX FLOAT, pY FLOAT, pZ FLOAT, rZ FLOAT, int INT )" ) ... executeSQLQuery( "INSERT INTO db_data( name, code, life, armor, skin, meele, gun, ammo, pX, pY, pZ, rZ, int ) VALUES( '"..getPlayerName( source ).."', '"..code.."', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0' )" )
-
Ye it get's values... addCommandHandler( "getid", function( player, cmd, target ) if ( getPlayerFromName( target ) ) then outputChatBox( "Das Ziel trägt die ID: "..tonumber( getSQLData( getPlayerFromName( target ), "db_data", "rowid" ) ), player, 255, 255, 0 ) end end ) error attempt to concatenate nil value
-
Database query failed near "select": sytnax error...
-
Thanks Castillo, I'll try it later.
-
function getSQLData( element, db, row ) local db = executeSQLSelect( db, "*", "name = '"..getPlayerName( element ).."'" ) if ( db and #db == 1 ) then return db[1][row] end end
-
Doesn't work... addCommandHandler( "getid", function( player, cmd, target ) if ( getPlayerFromName( target ) ) then outputChatBox( "Das Ziel trägt die ID: "..getSQLData( getPlayerFromName( target ), "db_data", "rowid" ), player, 255, 255, 0 ) end end )
-
executeSQLQuery( "CREATE TABLE db_data( id INT NOT NULL AUTO_INCREMENT, name STRING, code STRING, life INT, armor INT, skin INT, meele INT, gun INT, ammo INT, pX FLOAT, pY FLOAT, pZ FLOAT, rZ FLOAT, int INT )" ) executeSQLQuery( "INSERT INTO db_data( name, code, life, armor, skin, meele, gun, ammo, pX, pY, pZ, rZ, int ) VALUES( '"..getPlayerName( source ).."', '"..code.."', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0' )" ) error, database cannot be created. syntax error with auto increment.
-
hmm, createDB is buggy... database doesn't get created... addEventHandler( "onResourceStart", resourceRoot, function() executeSQLCreateTable( "db_data", "id INT IDENTITY( 1,1 ) PRIMARY KEY, name STRING, code STRING, life INT, armor INT, skin INT, meele INT, gun INT, ammo INT, pX FLOAT, pY FLOAT, pZ FLOAT, rZ FLOAT, int INT" ) end ) this works. but id is not in table...
-
But I must insert data into database first... otherwise it says error ...
-
lol any troubles cause this: executeSQLInsert( "db_data", ""0", '"..getPlayerName( source ).."', '"..code.."'" )