Jump to content

triggering Problem


Tockra

Recommended Posts

Posted

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 :-(

Posted

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 ?

Posted

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."

Posted

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...

Posted
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

Posted

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)!?...

Posted

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)

Posted

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

Posted

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

Posted

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 ...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...