Tockra Posted June 5, 2010 Share Posted June 5, 2010 Hello Guys... i have one problem in my script. My script want not trigger a serversite event onClientResourceStop: --Clientsite: function onPlayerQuit() GKtest = 0 --setElementData(getLocalPlayer(),"Bank[GKCrTime]",GKCrTime) triggerServerEvent( "playerDis", getLocalPlayer() ,GKCrTime,GKtest ) --GKCrTime is defined (its an numbered value between 1 and 2700) end addEventHandler("onClientResourceStop",getRootElement(),onPlayerQuit) --The Event: function quitPlayer(GKTime,SBTime) print("Test") local saved = mysql_query(Datenbank,"UPDATE `bankkonten` SET `GKCrTime`='"..tostring(GKTime).."',`SBCrTime`='"..tostring(SBTime).."',`GKAKT`='"..tostring(getElementData(source,"Bank[GKAKT]")).."',`SBAKT`='"..tostring(getElementData(player,"Bank[sBAKT]")).."' WHERE `Benutzername`='"..getPlayerName(source).."'") end addEvent("playerDis",true) addEventHandler("playerDis",getRootElement(),quitPlayer) But when i left the player, the script dont save the datas in the mysql table and it dont print "test" ... I dont know why but the Server Site event will not triggered... I have no idea why Link to comment
DEFCON1 Posted June 5, 2010 Share Posted June 5, 2010 I'm not sure, but the problem may be that there is a serverside callback called "onPlayerQuit". And there is a clientside callback "onClientPlayerQuit", might be what you need ? Link to comment
dzek (varez) Posted June 5, 2010 Share Posted June 5, 2010 yea, resource is not stopping on player disconnect.. and i dont know why you are doing this when you can use onPlayerQuit serverside? Link to comment
Tockra Posted June 6, 2010 Author Share Posted June 6, 2010 The variables are saved client site, because i have there a timer for better performance... onRessourceStop run when i quit the server... onClientPlayerQuit dont run client site because "This event is triggered when a remote player quits the game or leaves the server. It will not get triggered on the source player's client." Link to comment
dzek (varez) Posted June 6, 2010 Share Posted June 6, 2010 onRessourceStop run when i quit the server... not true Link to comment
Tockra Posted June 6, 2010 Author Share Posted June 6, 2010 I mean onClientResourceStop... And say not no i tested it. I included in this event outputChatBox("Test") . And when i disconnected i could read "test" in my console... Link to comment
dzek (varez) Posted June 6, 2010 Share Posted June 6, 2010 addEventHandler("onClientResourceStop", getResourceRootElement(getThisResource()), function() outputChatBox('triggered') triggerServerEvent('test', getLocalPlayer()) end) okay, ive tested it too.. well, i see the 'triggered' too, but server dont get any event triggered.. i think its just "too late" to trigger event on this.. maybe try to setElementData from time to time, and catching it server side on quit? i see no better way Link to comment
Tockra Posted June 6, 2010 Author Share Posted June 6, 2010 Yes that would run but i want not use it because every secound the variable get +1 and when for every player set every secound his Element Data, it isnt so good for the serverperformance, because setElementData saved the Element Data on the server (i think)!?... Link to comment
dzek (varez) Posted June 6, 2010 Share Posted June 6, 2010 isnt it possible to make the timer server side? element data is synchronized if you want to (default its synchronized, but you can disable it on setElementData) Link to comment
Tockra Posted June 6, 2010 Author Share Posted June 6, 2010 If i make the timer server site it is badder for the performance then when i use setElementData every secound... Link to comment
dzek (varez) Posted June 6, 2010 Share Posted June 6, 2010 why? could you explain what are you trying to do? Link to comment
Tockra Posted June 6, 2010 Author Share Posted June 6, 2010 i have a variable for every player where will every secound added +1 ... Link to comment
dzek (varez) Posted June 6, 2010 Share Posted June 6, 2010 so whats the problem of making it server side? you dont have to increase value every second. you can also save "start time" and just do math when you need that value Link to comment
Tockra Posted June 6, 2010 Author Share Posted June 6, 2010 Serverside is it badder for the performance, when the server loop every secound all players... Link to comment
dzek (varez) Posted June 6, 2010 Share Posted June 6, 2010 well, i think server got better performance running only server than client pc running the game.. and i told you, you dont have to increase value every 1 sec. just do something like: -- include this: -- [url=https://wiki.multitheftauto.com/wiki/GetTimestamp]https://wiki.multitheftauto.com/wiki/GetTimestamp[/url] -- and all functions it needs too!! startTime = getTimestamp() -- and when you need to get the value: function getValue() return getTimestamp() - startTime end -- and you have your value i see you have some english difficulties, but i hope you can understand me Link to comment
Tockra Posted June 6, 2010 Author Share Posted June 6, 2010 Thank you that is a nice idea I will test it €: I have one problem i dont understand what getTimestamp() return... I would test it and used this : http://www.pastebay.com/102263 But i get this error: attempt to call global getTimestamp (a nil value) Link to comment
dzek (varez) Posted June 6, 2010 Share Posted June 6, 2010 this wiki page have one bug i think: outputChatBox(tostring(getTimestamp())) function GetTimestamp(year, month, day, hour, minute, second) -- .. see the difference in function name? 1st capital letter? fix it. what is timestamp? its int type number - time in seconds from 01.01.1970 http://en.wikipedia.org/wiki/Timestamp Link to comment
Tockra Posted June 6, 2010 Author Share Posted June 6, 2010 Okay thx i will test it again ^^ €: Now comes ERROR: attempt to call global IsYearALeapYear (a nil value) look like very buggy function o0 ? €²: Sorry my failor, i used the wrong function in my script ... Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now