XetaQuake Posted October 21, 2008 Share Posted October 21, 2008 Hey, i have a strange problem, and its realy strange to explain it ^^ but i try it, and hope somebody can help me: When a player write a command, let´s say /test, then a triggerEvent launches. And now there comes the problem: triggerEvent fires a server-side function, to set the player invisible who has writen /test in the other function. But now all players get invisible, not only the player who has writen /test. Normaly, its easy to fix it when you use source or so, but the problem in my issue is, that not the source fires the function to set the player invisible - the triggerEvent is firing it. I hope you can understand it. Here is a little part of my code (translated in english and also cutted for this post): Function that starts when player writing /test on function testFunction ( source, command, status ) invisiblePlayerName = getClientName ( source ) invisiblePlayerSource = getPlayerFromNick ( invisiblePlayerName ) if ( status == "an" ) or ( status == "on" ) then setTimer ( triggerEvent, 30000, 1, "nowFireNextFunction", invisiblePlayerSource ) else outputChatBox ( "Pleas use ''/test on''", source, 201, 201, 244, true ) end end addCommandHandler ( "test", testFunction ) addEvent( "nowFireNextFunction", true ) addEventHandler ( "nowFireNextFunction", getRootElement(), nextFunction ) Function there get firing with triggerEvent on previous code function nextFunction( source ) setElementAlpha ( invisiblePlayerSource, 110 ) outputChatBox ( invisiblePlayerName.." ist now invisible", getRootElement(), 255, 188, 178, true ) else end end I hope you can help me, the problem is (i´m think so) that´s triggerEvent is not a source player, and so no source-player launches the second function - only triggerEvent. And so there´s no source player to set him invisible I would prefer to set the player invisible client-side (so i can use getLocalPlayer), but then its not synchronized Any tips for me? - Pleas XetaQuake Link to comment
DiSaMe Posted October 21, 2008 Share Posted October 21, 2008 invisiblePlayerName = getClientName ( source ) invisiblePlayerSource = getPlayerFromNick ( invisiblePlayerName ) Why is this for? Maybe you could just change setTimer ( triggerEvent, 30000, 1, "nowFireNextFunction", invisiblePlayerSource ) to setTimer(nextFunction, 30000, 1,source) But I don't know about this, maybe it's only when both functions are in the same file. Link to comment
Ace_Gambit Posted October 21, 2008 Share Posted October 21, 2008 Alpha is triggered on all models with the same id. It doesn't matter if you pass a source argument. Setting CJs' alpha to 0 for example, makes all players with the same skin id invisible as well. Same goes for vehicles. Link to comment
XetaQuake Posted October 21, 2008 Author Share Posted October 21, 2008 Alpha is triggered on all models with the same id. It doesn't matter if you pass a source argument. Setting CJs' alpha to 0 for example, makes all players with the same skin id invisible as well. Same goes for vehicles. Oh realy? Thats to bad! But thanks for answer Then i doesn't use setElementAlpha, i think i let the player glow - is also nice. But, pleas don´t forgot, this code snippet is only a LITTLE part from my script. Also the player who should getting invisible, should be get invincible. But: All players get invincible, but my script to set the player invincible is client-side: function setPlayerInvincible ( authorization ) if ( authorization == "allowed" ) then addEventHandler ( "onClientPlayerDamage", getRootElement(), cancelEvent ) else ... end end So any damage get ignored. And i fire the client-side script using triggerClientEvent on "nextFunction": (this lines was not on the old post, because i thought i can get the answer with my invisible problem) function nextFunction( source ) setElementAlpha ( invisiblePlayerSource, 110 ) triggerClientEvent ( "invincible", invisiblePlayerSource, "allowed" ) outputChatBox ( invisiblePlayerName.." ist now invisible", getRootElement(), 255, 188, 178, true ) else end end But there is a similar problem: Anybody gets invincible - but WHY? I also tries it with source instead of invisiblePlayerSource (to answer Doomed_Space_Marine´s post), but its the same problem Ideas pleas? Link to comment
Lordy Posted October 21, 2008 Share Posted October 21, 2008 bool triggerClientEvent ( [element triggerFor=getRootElement()], string name, element theElement, [arguments...] ) Please see the triggerFor argument if that is not defined, it triggers it for all clients Link to comment
XetaQuake Posted October 21, 2008 Author Share Posted October 21, 2008 Oh, well, thanks LordAzamth Now i use: triggerClientEvent ( "invincible", invisiblePlayerSource, "allowed", invisiblePlayerSource ) But i have the same problem, anybody is invincible. And, anyway, for my eyes it looks a little bit stupid ^^ two times invisiblePlayerSource? Link to comment
Willy Posted October 21, 2008 Share Posted October 21, 2008 erm you did it wrong again... triggerfor is the first argument... Link to comment
Gamesnert Posted October 21, 2008 Share Posted October 21, 2008 bool triggerClientEvent ( [element triggerFor=getRootElement()], string name, element theElement, [arguments...] ) Meaning triggerClientEvent ( invisiblePlayerSource, "invincible", invisiblePlayerSource, "allowed" ) 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