Jump to content

WhoAmI

Members
  • Posts

    1,248
  • Joined

  • Last visited

Everything posted by WhoAmI

  1. And now It is better to use db function (dbQuery, dbExec, dbPoll), couse of performance and SQL injections.
  2. SELECT * FROM accounts WHERE username=? And then dbPoll, then you can download all records.
  3. Better idea would be to save into table, and when player leaves server - saves the values in table. That would be better prefomance, couse you wouldn't ask MySQL every action.
  4. So you are doing right thing.
  5. Well, I dont really know what you mean. You want get username from what? From database? You can get it in login function and saves into element data.
  6. You are welcome. Have fun with SQL.
  7. dbExec ( "UPDATE tableName SET x=?, y=?, z=?, skin=? WHERE username=?", x, y, z, skin, username ) Do you understand now?
  8. So as I said, 'UPDATE'.
  9. Oh, so dbExec ( connect, "INSERT INTO accounts ( username, money,skin,health,x,y,z,int,dim ) VALUES (?,?,?,?,?,?,?,?,? )", username, money, skin, healt, x, y, z, int, dim )
  10. dbExec ( "UPDATE tableName SET x=? WHERE username=?", x, username )
  11. What the hell? Try to output elemnt after 1st lane outputChatBox ( getElementType ( source ) )
  12. Are you sure if it is serverside script in meta?
  13. function onQuit () local data = getElementData(source,"LoggedIN") outputDebugString ( tostring ( data ) ) if ( data ) then local money = getPlayerMoney ( source ) local skin = getPedSkin ( source ) local health = getElementHealth ( source ) local int,dim = getElementInterior ( source ), getElementDimension ( source ) local x,y,z = getElementPosition (source) local inserting = dbExec ( connect, "INSERT INTO accounts ( money,skin,health,x,y,z,int,dim ) VALUES (?,?,?,?,?,?,?,? )", money, skin, healt, x, y, z, int, dim ) if inserting then outputDebugString("Inserting successfull") else outputDebugString("Inserting failed.") end end end addEventHandler ("onPlayerQuit", root, onQuit) Check this out.
  14. And I want to know how would you whose this values are? I mean that you are not saving id of player or account.
  15. Well, when you quit the values are not saving?
  16. Of course it outputs nothing. function onQuit () if ( getElementData(source,"LoggedIN") ) then outputChatBox("GetElementData Successfull") local x,y,z = getElementPosition (source) local inserting = dbExec ( connect, "INSERT INTO accounts ( money,skin,health,x,y,z,int,dim ) VALUES (?,?,?,?,?,?,?,? )",tostring (getPlayerMoney (source)),tostring (getPedSkin (source)),tostring (getElementHealth (source)),x,y,z,getElementInterior (source),getElementDimension (source) ) if inserting then outputChatBox("Inserting successfull") else outputChatBox("Inserting failed.") end end end addEventHandler ("onPlayerQuit", root, onQuit) And you don't need to do such a thing if getElementData(localPlayer,"LoggedIN") == true then Just do if ( getElementData(source,"LoggedIN") ) then @UP: dbExec returns true if succesfully, false otherwise.
  17. And there also try to output data outputChatBox ( tostring ( getElementData ( localPlayer, "LoggedIN" ) ) )
  18. So it's kinda bug. Anyway, if you don't use returns of setElementData, just delete variable.
  19. Try to add after 8th lane outputChatBox ( tostring ( getElementData ( player, "LoggedIN" ) ) )
  20. Well, that is strange. outputChatBox(tostring(elementdata)) This outputs false?
  21. Are you sure that you put player in 1st argument to call this function? After 2nd line add outputChatBox ( getElementType ( player ) )
  22. Those messages after loggin in are showing?
  23. Well, your code is right, but I would add some corrects: function mamoney (thePlayer, cmd) local money = getPlayerMoney(thePlayer) if ( money >= 0) then outputChatBox( "Your current money is "..money, thePlayer, 0, 255, 0) else outputChatBox( "Your current money is "..money, thePlayer, 255, 0, 0) end end addCommandHandler ("money", mamoney) What have I done? Firstly, I added local in your variable. For what? It is better to use local inside function, if you won't use this variable in other functions local money = getPlayerMoney(thePlayer) And after I added 'thePlayer' on 2nd argument in outputChatBox function, why? Then it will output this message for player, who execute this command, otherwise this message would be shown for all players in server. outputChatBox( "Your current money is "..money, thePlayer, 0, 255, 0) Finally I changed colors. The maximal amount of colors in r, g, b is 255.
  24. WhoAmI

    help event

    function name ( ) removeEventHandler ( "onClientPlayerWeaponSwitch", root, name ) -- todo end addEventHandler ( "onClientPlayerWeaponSwitch", root, name )
×
×
  • Create New...