Vice City: Multiplayer

VC:MP Discussion => Support => Topic started by: D4rkR420R on Jul 12, 2017, 04:02 AM

Title: I need help...
Post by: D4rkR420R on Jul 12, 2017, 04:02 AM
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.
Title: Re: I need help...
Post by: aXXo on Jul 12, 2017, 11:37 PM
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 (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/SetWastedSettings) 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 );
}
Title: Re: I need help...
Post by: D4rkR420R on Jul 13, 2017, 02:29 AM
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.
Title: Re: I need help...
Post by: D4rkR420R on Jul 14, 2017, 02:17 PM
Bump.
Title: Re: I need help...
Post by: Thijn on Jul 14, 2017, 05:25 PM
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.
Title: Re: I need help...
Post by: Cool on Jul 14, 2017, 06:12 PM
Copy cat @Zeeshan.
Title: Re: I need help...
Post by: D4rkR420R on Jul 14, 2017, 06:28 PM
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.
Title: Re: I need help...
Post by: D4rkR420R on Jul 16, 2017, 02:18 AM
Bump. Topic unseen from many people ;-;
Title: Re: I need help...
Post by: Xmair on Jul 16, 2017, 04:02 PM
In the GunGameWinner function, you're setting "player"'s stuff instead of "plr"
Title: Re: I need help...
Post by: D4rkR420R on Jul 17, 2017, 02:55 AM
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?
Title: Re: I need help...
Post by: D4rkR420R on Jul 24, 2017, 06:31 PM
Bump. I want to keep the topic in public for any support out there. BTW, it seems the auto-spawn it's bugged.
Title: Re: I need help...
Post by: NicusorN5 on Jul 24, 2017, 07:55 PM
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.
Title: Re: I need help...
Post by: D4rkR420R on Jul 30, 2017, 03:42 PM
This situation been solved, thanks to Decent for being a kind person. This issue is known as solved.