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

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

yea, resource is not stopping on player disconnect..

and i dont know why you are doing this when you can use onPlayerQuit serverside?

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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

h32yhix1ossu.png
Posted
onRessourceStop run when i quit the server...

not true

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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

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

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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

h32yhix1ossu.png
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)

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

why?

could you explain what are you trying to do?

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

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

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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

h32yhix1ossu.png

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