Moderators IIYAMA Posted May 7, 2013 Moderators Share Posted May 7, 2013 If I start my script it will trigger to server side, to check if the player is login. What is the best way to check if the player did not just joined. This one must only be triggered(to server side) when the player is already in game. (client) addEventHandler( "onClientResourceStart", resourceRoot, function () triggerServerEvent("clientLoaded",localPlayer) end) Link to comment
iPrestege Posted May 7, 2013 Share Posted May 7, 2013 Do you mean you want to check if the player has been logging into the server or not? Link to comment
PaiN^ Posted May 7, 2013 Share Posted May 7, 2013 I would say element data is the best way . Link to comment
denny199 Posted May 7, 2013 Share Posted May 7, 2013 What is the best way to check if the player did not just joined. I didn't understand that at all https://wiki.multitheftauto.com/wiki/IsTransferBoxActive Maybe I didn't understood you at all but maybe is this something:? function dl() if (isTransferBoxActive() == false) then triggerServerEvent("clientLoaded",localPlayer) else if ( isTimer( chektimer ) ) then --just incase killTimer ( chektimer ) end end end addEventHandler( "onClientResourceStart", resourceRoot, function () chektimer = setTimer(dl, 2000, 0) end) You want to chek if the player is logged in or so from the client? or do you want to chek if the player has logged in but not the people who are joined? Can you tell it me maybe what you trying to do? Link to comment
Moderators IIYAMA Posted May 7, 2013 Author Moderators Share Posted May 7, 2013 Well as sample: There 3 players in-game and 1 player is going to join. When I start the resource, the 3 players are triggering to serverside. Next the other player joins the server and he triggered too. <-- and this is what I want to be prevent from happening. I tried to use getTickCount(), to get: This function returns amount of time that your system has been running in milliseconds. By comparing two values of getTickCount, you can determine how much time has passed (in milliseconds) between two events. This could be used to determine how efficient your code is, or to time how long a player takes to complete a task. But some how the tickcount is already changing after I started mta or when I reconnect to the server. (so I can't check if this player is new or already in game) ElementData isn't a solution, this script probably triggerd faster then the elementData reached the player who is downloading, next to that is is laggy, because all new client players have to download each other status. NL: Ik wil gewoon weten of de speler nieuw is of al in game is, so dat ik kan bepalen of ik het wil sturen of niet. Link to comment
TAPL Posted May 7, 2013 Share Posted May 7, 2013 -- Client Side -- addEventHandler("onClientResourceStart", resourceRoot, function() if getElementData(localPlayer, "Whatever") then triggerServerEvent("clientLoaded", localPlayer) end end) -- Server Side -- addEventHandler("onResourceStart", resourceRoot, function() for i, player in ipairs (getElementsByType("player")) do setElementData(player, "Whatever", true) end end) Link to comment
Moderators IIYAMA Posted May 7, 2013 Author Moderators Share Posted May 7, 2013 aha well it may will work, but one trigger is something you can't compare with: elementdata*playerCount Thx anyway guys. Link to comment
novo Posted May 7, 2013 Share Posted May 7, 2013 You can make the player download a file where you can set when the player logs in for first time: (https://wiki.multitheftauto.com/wiki/xmlCreateFile) <configuration> <loggedbefore = "false"> </configuration> Link to comment
TAPL Posted May 7, 2013 Share Posted May 7, 2013 ahawell it may will work, but one trigger is something you can't compare with: elementdata*playerCount Thx anyway guys. You don't want use elementdata? Well another way, let everyone do the trigger and in the same time in server side put all players in the server in a table and when the trigger come from the client check if the source of the trigger was in the table or not. Link to comment
Moderators IIYAMA Posted May 7, 2013 Author Moderators Share Posted May 7, 2013 ah yes, but then I am sending this trigger. It doesn't really matter if it have been send, it was more meant to save data travel by preventing the trigger. Well it is just a trigger... but it is handy to know if there is a possibility to find a way to do this on client side, without using any extra bandwidth. Link to comment
denny199 Posted May 7, 2013 Share Posted May 7, 2013 Use variables on the server side... For example: local canjoin = true addEventHandler( "onPlayerJoin", root, -- or onPlayerLogin function () if ( canjoin == false ) then outputChatBox ( "You can't join the spy-vs-spy game, spectator mode started.", source, 255,0,0, true ) elseif ( canjoin == true ) then outputChatBox ( "You joined the spy-vs-spy game!", source, 255,0,0, true ) end end) And then you should edit your system ;p It's the fasted way. edit: or contact me on skype edit2: If you want to get it on the client side you need to store the data in a table, and then trigger the tabledata to the client, but I prefer server side. edit3(0.o):Why do you actaully want this on your new gamemode , it's just funnier to play direct instead of waiting.. Link to comment
Moderators IIYAMA Posted May 7, 2013 Author Moderators Share Posted May 7, 2013 I don't think you understand what I mean. I am talking about something very simple. But now I know it is impossible, without using timers. 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