Adde Posted March 22, 2013 Share Posted March 22, 2013 (edited) Hello, I tried to make a function that sets the players team to "offline" when it´s guestaccount, but the problem is that those who register spawn under the ground and nothing happends, they should spawn in army, on a special position, with money, etc on register. I know that this is totaly wrong and I understand why. So how can I do to make it work? function onPlayerSpawn (player) sourceAccount = getPlayerAccount ( source ) if isGuestAccount ( sourceAccount ) then setPlayerTeam (source, offline) else setPlayerTeam ( source, Army ) setElementPosition ( source, 238.4085, 1909.1389, 17.84 ) givePlayerMoney ( source, 2000 ) setElementModel( source, 179 ) setPlayerNametagColor ( source, 59, 166, 109 ) end end addEventHandler ( "onPlayerJoin", getRootElement(), onPlayerSpawn ) Edited March 22, 2013 by Guest Link to comment
manawydan Posted March 22, 2013 Share Posted March 22, 2013 try. no tested function onPlayerSpawn (thePlayer) sourceAccount = getPlayerAccount ( thePlayer ) if isGuestAccount ( sourceAccount ) then setPlayerTeam (thePlayer, offline) else setPlayerTeam ( thePlayer, Army ) setElementPosition ( thePlayer, 238.4085, 1909.1389, 17.84 ) givePlayerMoney ( thePlayer, 2000 ) setElementModel( thePlayer, 179 ) setPlayerNametagColor ( thePlayer, 59, 166, 109 ) end end addEventHandler ( "onPlayerJoin", getRootElement(), onPlayerSpawn ) Link to comment
Adde Posted March 22, 2013 Author Share Posted March 22, 2013 No don´t work. It´s nothing wrong with source and player. It´s the script, i need help with how to set the team to offline when player is not logged in and then if the player register it sets to another. But it should not make it change the saved teams for players that´s already registered. Link to comment
Castillo Posted March 22, 2013 Share Posted March 22, 2013 "offline" and "Army" variables are defined? Link to comment
-ffs-Sniper Posted March 22, 2013 Share Posted March 22, 2013 How can a player be logged in when onPlayerJoin is triggered? The player will always be set to offline team this way. In order to get this working you need to trigger an event right after the player is logged in (preferably use onPlayerLogin instead of onPlayerJoin). Link to comment
Sasu Posted March 22, 2013 Share Posted March 22, 2013 Try this: function onPlayerJoin() offline = getTeamFromName ( "offline" ) setPlayerTeam ( source, offline ) end addEventHandler("onPlayerJoin", getRootElement(), onPlayerJoin) function onPlayerLogin() Army = getTeamFromName( "Army" ) setPlayerTeam ( source, Army ) setElementPosition ( source, 238.4085, 1909.1389, 17.84 ) givePlayerMoney ( source, 2000 ) setElementModel( source, 179 ) setPlayerNametagColor ( source, 59, 166, 109 ) end addEventHandler("onPlayerLogin", getRootElement(), onPlayerLogin) Would be this ffs-sniper? Link to comment
-ffs-Sniper Posted March 22, 2013 Share Posted March 22, 2013 Yep, that should be working. Link to comment
Adde Posted March 23, 2013 Author Share Posted March 23, 2013 Yes I have tried that before, but the problem is if I´m saved in an other team when i logout and then login I spawn in army. It should not be like that. I s Link to comment
Sasu Posted March 23, 2013 Share Posted March 23, 2013 Yes I have tried that before, but the problem is if I´m saved in an other team when i logout and then login I spawn in army. It should not be like that. I s Post the function when you save the team. Link to comment
Adde Posted March 23, 2013 Author Share Posted March 23, 2013 Yes I have tried that before, but the problem is if I´m saved in an other team when i logout and then login I spawn in army. It should not be like that. I s Post the function when you save the team. Save team works correctly, it´s the script that just makes the player join offline team when it´s a guest account that I don´t know how to fix. viewtopic.php?f=91&t=55069 Link to comment
Sasu Posted March 23, 2013 Share Posted March 23, 2013 So, only copy that: function onPlayerJoin() offline = getTeamFromName ( "offline" ) setPlayerTeam ( source, offline ) end addEventHandler("onPlayerJoin", getRootElement(), onPlayerJoin) 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