Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Donate
Collapse

Plutonium

  1. Home
  2. BO2 Modding Support & Discussion
  3. self waittill("spawned_player"); not working properly

self waittill("spawned_player"); not working properly

Scheduled Pinned Locked Moved BO2 Modding Support & Discussion
3 Posts 2 Posters 182 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Gangorraundefined Offline
    Gangorraundefined Offline
    Gangorra
    wrote on last edited by
    #1

    Hey guys,
    So I've a 'noobFriendly()' function in which I give the late coming player Juggernog and Money.

    It works when the player spawns. That's ok. The problem is this function is running even when spectating, pre-spawning.

    Can someone help me??

    init()
    {
    	level.perk_purchase_limit = 9;
    	level.get_player_weapon_limit = 3;
    	thread gscRestart();
            thread setPlayersToSpectator();
            level thread onPlayerConnect();
           for(;;)
           {
            level waittill("connected", player);
    		player thread [[level.givecustomcharacters]]();
          }
    }
    
    onPlayerConnect()
    {
        for(;;)
        {
            level waittill("connected", player);
            player thread onPlayerSpawned();
           	player thread noobFriendly();
           	self iprintln("^2Bem-vindo ao Zombies ^1Gangorra Aidetica!");
        }
    }
    
    onPlayerSpawned()
    {
        self endon("disconnect");
    	level endon("game_ended");
        for(;;)
        {
            self waittill("spawned_player");
    		// Will appear each time when the player spawn, that's just an exemple.
    		//self iprintln("^2Bem-vindo ao Zombies ^1Gangorra Aidetica!");
        }
    }
    
    noobFriendly()
    {
    	self endon("disconnect");
    	level endon("game_ended");
    	alreadySpawned = false; //to avoid rewarding when RE-spawning | not tested
    	for(;;)
    	{
    		self waittill("spawned_player");
    		wait 7;
    		if(level.round_number > 1 && !alreadySpawned)
    		{
    			alreadySpawned = true;
    			reward = level.round_number * 500;
    			self.score += reward;
    			self iPrintln("^7Voce recebeu ^1Juggernaut e ^2$" + reward + " ^7para nao ficar em desvantagem.");
    			self doGivePerk("specialty_armorvest");
    		}
    	}
    }
    
    1 Reply Last reply
    0
    • Xerxesundefined Offline
      Xerxesundefined Offline
      Xerxes Plutonium Staff
      wrote on last edited by
      #2

      Can't help you without the full script.

      Gangorraundefined 1 Reply Last reply
      0
      • Gangorraundefined Offline
        Gangorraundefined Offline
        Gangorra
        replied to Xerxes on last edited by Gangorra
        #3

        Xerxes

        This was the relevant part because this script has a lot of fixes such as tombstone and map restart, but I ended up fixing it by myself.

        In general here's what I did:

        player thread noobFriendly();
        to
        self thread noobFriendly();
        on onPlayerConnect() solved the most part of the problem.

        Also, moving the call of noobFriendly() from onPlayerConnect() to onPlayerSpawn()

        and removing the infinite loop on onPlayerSpawn() because for my script it's simply unnecessary.

        I'm a front-end dev with some years of back-end experience and still getting the hang of lua.

        We can happily close this thread

        1 Reply Last reply
        0

        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Donate