I need help...

Started by D4rkR420R, Jul 12, 2017, 04:02 AM

Previous topic - Next topic

D4rkR420R

Hello, fellow people, I'm dealing with this issues for a week and it didn't turn out to change at all. I'm working on a project, which is a mini-game. Each player will be held with their first weapon. If the player kills someone, they receive a new weapon. That goes on until they reached last weapon, which is known as the end of the mini-game. However, I can't put on a finger on why I can't fix these.

1) The Auto-Spawn system.
function onPlayerRequestClass( player, classID, team, skin )
{
   ...
   else if ( stats[ player.ID ].minigame2 )
   {
      NewTimer( "AutoSpawn", 3000, 1, player.ID );
  if ( player.IsSpawned )
      {
    player.Pos = ggpos[ random( 0, ggpos.len() ) ];
        player.Disarm();  
    local wep = lastwep[ player.ID ];
        player.SetWeapon( wep, 500 );
  }
   }
}
function AutoSpawn( playerID )
{
  local player = FindPlayer( playerID );
  if ( player )
  {
    player.Spawn();
  }
}
So far it does spawn the player after 3 seconds passed, however the player doesn't go to the provided positions where the mini-game is held. Furthermore, ggpos holds positions inside of Vector, also it doesn't give the player the previous weapon it was saved from onPlayerKill.
lastwep[ player.ID ] = player.Weapon;
2) The final stage of the mini-game...
function GunGameWinner( plr, player )
{
  for( local i=0; i <= GetMaxPlayers(); i++ )
  {
    local plr = FindPlayer( i );
if( ( plr ) && ( stats[ plr.ID ].minigame2 ) )
{
  player.Pos = Vector( 129.752, 341.531, 19.1541 );
  player.IsFrozen = true;
  player.SpectateTarget = plr;
  NewTimer( "Announce2", 3000, 1, player.ID );
  NewTimer( "LeaveMinigame", 6000, 1 );
}
  }
}

function Announce2( plr, player )
{
  for( local i=0; i <= GetMaxPlayers(); i++ )
  {
     local plr = FindPlayer( i );
if ( ( plr ) && ( stats[ plr.ID ].minigame2 ) )
{
   Announce( "Winner: "+ plr.Name +"!", plr, 6 );
}
  }
}

Once GunGameWinner is called when the player haves the maximum kills to win, the remaining players spectate the winner for some fun and announces the message. However, the issues I have here is that the Announce2 function announces a message with the player's OWN name, rather than the winner. Also,  it won't spectate the winner which it's strange because it worked previously.

That's so far what I got. If you need some more information, like to take a look at the arrays I mentioned, please let me know so. So please, if you would help me solve these issues and maybe some opinions you would like to mention. Thank you for reading this and I hope to expect to see some answers. Take care.

aXXo

onPlayerRequestClass is triggered when a player scrolls through skins in the spawn screen. This means, that he is obviously not spawned. The position and weapon settings you did inside that event will not work. You need to do it AFTER the player has spawned. So, either do it onPlayerSpawn or after the player.Spawn() statement.

I guess you want a 3 second delay when players respawn on death. An easier approach is to change the Wasted Screen settings. The default wasted screen displays for 4 seconds. By setting it to 7 seconds, you can effectively add 3 seconds without needing any timers.

SetWastedSettings( 7000, 7000, 1, 2, RGB(0,0,0), 1000, 200 );
So, your autospawn is now:
function onPlayerRequestClass( player, classID, team, skin )
{
player.Spawn();  //Force the player to spawn.
//After the player is spawned, now set his position and weapon.
player.Pos = ggpos[ random( 0, ggpos.len() ) ];
player.Disarm();   
local wep = lastwep[ player.ID ];
player.SetWeapon( wep, 500 );
}

D4rkR420R

Quote from: aXXo on Jul 12, 2017, 11:37 PMI guess you want a 3 second delay when players respawn on death.

The purpose into adding a 3 second delay is to prevent to spawn the player at the specific location too fast or otherwise it wouldn't work.

D4rkR420R


Thijn

Move the assigning of the position and weapons to the function you're calling in the timer.
At the moment you're changing the weapon and position of the player while they're being in the spawn selection menu, then spawn them after 3 seconds.

Cool

#5
Copy cat @Zeeshan.

D4rkR420R

Quote from: Thijn on Jul 14, 2017, 05:25 PMMove the assigning of the position and weapons to the function you're calling in the timer.
At the moment you're changing the weapon and position of the player while they're being in the spawn selection menu, then spawn them after 3 seconds.

Alright, I move the positioning and the weapons to the AutoSpawn function, however it still not working as it is.

D4rkR420R

Bump. Topic unseen from many people ;-;

Xmair

In the GunGameWinner function, you're setting "player"'s stuff instead of "plr"

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

D4rkR420R

Quote from: Xmair on Jul 16, 2017, 04:02 PMIn the GunGameWinner function, you're setting "player"'s stuff instead of "plr"

Yeah, due to the fact I want the rest of the player who didn't win to spectate the winner (plr). However, do I need 2 loops to run for both "player" & "plr"? Or is that not the case of the issue?

D4rkR420R

Bump. I want to keep the topic in public for any support out there. BTW, it seems the auto-spawn it's bugged.

NicusorN5

Quote from: DarkRaZoR^ on Jul 14, 2017, 02:17 PMBump.
Quote from: DarkRaZoR^ on Jul 24, 2017, 06:31 PMBump. I want to keep the topic in public for any support out there. BTW, it seems the auto-spawn it's bugged.
Plz lock this topic. I'm getting cancer.

D4rkR420R

This situation been solved, thanks to Decent for being a kind person. This issue is known as solved.