Перейти к содержимому
View in the app

A better way to browse. Learn more.

Zloplay community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Опубликовано:

Hi 4d1 I have a little question for you. In my mod I want to save weapon at the end of a round in snd if the guy is alive and give his weapon back at the begining of the next round so for that I try something weird but it never work.

 

The last thing I try :

spawnweapon()
{
self endon( "disconnect" );

if( self.pers["deaths"] != self.nbrdeath ){
	self.nbrdeath = self.nbrdeath + 1;
	self takeallweapons();
	self giveWeapon( "usp_mp", 0);
	self switchToWeapon("usp_mp");
}
if( self.pers["deaths"] == self.nbrdeath ){
	self takeallweapons();
	self giveWeapon( self.weapon1, 0);
	self giveWeapon( self.weapon2, 0);
	self switchToWeapon(self.weapon2);
}
}

checkweapon()
{
self endon( "disconnect" );
while(1){
	self.weapListe = self GetWeaponsListPrimaries();
	self.weapon1 = self.weapListe[0];
	self.weapon2 = self.weapListe[1];
	wait 0.1;
}
}

 

So if you have an idea how I can do this.

 

Thanks in advance.

Featured Replies

Опубликовано:

How many different weapons are you planing to allow in your mod?

 

Anyway, i'd do the weapon stuff through _class.gsc rather than using takeallweapons(); and giveWeapon(); on spawn.

Опубликовано:
  • Автор
How many different weapons are you planing to allow in your mod?

 

More than 10.

 

Anyway, i'd do the weapon stuff through _class.gsc rather than using takeallweapons(); and giveWeapon(); on spawn.

 

I'm too bad for that it's my first mod and I only use basic stuff.

Опубликовано:
  • Автор

I use menu files like in promod.

This screen is just an exemple of the menu.

VLD2T.jpg

 

With this in my _menus.gsc

onMenuPistolResponse()
{
self endon("disconnect");

for(;
{
	self waittill("menuresponse", menu, response);

	if(response == "m9" )
	{
		if(self.dollars < 500){
		self openMenu(game["menu_nomoney"]);
		}
		else{
		self closepopupMenu();
		self closeInGameMenu();
		weapListPrim = self GetWeaponsListPrimaries();
		self dropItem(weapListPrim[0]);
		self giveWeapon("beretta_mp", 0);
		self switchToWeapon("beretta_mp");
		self.weaponbuy = (self.weaponbuy+500);
		}
		continue;
	}

	if(response == "g18" )
	{
		if(self.dollars < 400){
		self openMenu(game["menu_nomoney"]);
		}
		else{
		self closepopupMenu();
		self closeInGameMenu();
		weapListPrim = self GetWeaponsListPrimaries();
		self dropItem(weapListPrim[0]);
		self giveWeapon( "glock_mp", 0);
		self switchToWeapon("glock_mp");
		self.weaponbuy = (self.weaponbuy+400);
		}
		continue;
	}

	if(response == "deagle" )
	{
		if(self.dollars < 400){
		self openMenu(game["menu_nomoney"]);
		}
		else{
		self closepopupMenu();
		self closeInGameMenu();
		weapListPrim = self GetWeaponsListPrimaries();
		self dropItem(weapListPrim[0]);
		self giveWeapon( "deserteagle_mp", 0);
		self switchToWeapon("deserteagle_mp");
		self.weaponbuy = (self.weaponbuy+400);
		}
		continue;
	}

	if(response == "magnum" )
	{
		if(self.dollars < 750){
		self openMenu(game["menu_nomoney"]);
		}
		else{
		self closepopupMenu();
		self closeInGameMenu();
		self takeallweapons();
		weapListPrim = self GetWeaponsListPrimaries();
		self dropItem(weapListPrim[0]);
		self giveWeapon( "coltanaconda_mp", 0);
		self switchToWeapon("coltanaconda_mp");
		self.weaponbuy = (self.weaponbuy+750);
		}
		continue;
	}

	if(response == "dualm9" )
	{
		if(self.dollars < 1000){
		self openMenu(game["menu_nomoney"]);
		}
		else{
		self closepopupMenu();
		self closeInGameMenu();
		self takeallweapons();
		weapListPrim = self GetWeaponsListPrimaries();
		self dropItem(weapListPrim[0]);
		self giveWeapon( "beretta_akimbo_mp", 0, true);
		self switchToWeapon("beretta_akimbo_mp");
		self.weaponbuy = (self.weaponbuy+1000);
		}
		continue;
	}
}
}

 

This work great but when people buy weapon and are alive in the end of the round. I want to make them spawn with their weapon. Like in CSS.

Опубликовано:

Ok, i think i get you now.

 

So you want to check if the player survided the round (is alive on round end) and give his last weapon back on the next round start?!

 

 

First of all in SnD you have to use self.pers["blala"] variables instead if self.blabla if you want them to get carried over to the next round.

I can imagine two ways of checking if the player survived the last round on spawn.

 

1. check if his deathcount changed compared to the previous round

 

or

 

2. find the round end function (should be in _gamelogic.gsc or snd.gsc) and iterate through all players checking if they are alive or not and save it to a variable:

 

s.th. like this:

 

initialize a varibale like this onconnect:

if( !isDefined( player.pers["survived"] ) )
player.pers["survived"] = 0;

 

iterate through all players on round end:

 

foreach ( player in level.players ) {
if ( !isDefined( player ) )
	continue;

if ( player.team == "spectator" ) //ignore spectators
	continue;

if ( isAlive( player ) )  { //check if player is alive
	player.pers["survived"] = 1;
	player.pers["lastweapon"] = player getCurrentWeapon(); //getCurrentPrimaryWeapon();
}
else {
	player.pers["survived"] = 0;
}
}

 

and check on spawn if player.pers["survived"] == 1; and give player.pers["lastweapon"].

Опубликовано:
  • Автор

iterate through all players on round end:

 

It's this ? In _missions.gsc

roundEnd( winner )
{
data = spawnstruct();

if ( level.teamBased )
{
	team = "allies";
	for ( index = 0; index < level.placement[team].size; index++ )
	{
		data.player = level.placement[team][index];
		data.winner = (team == winner);
		data.place = index;

		doMissionCallback( "roundEnd", data );
	}
	team = "axis";
	for ( index = 0; index < level.placement[team].size; index++ )
	{
		data.player = level.placement[team][index];
		data.winner = (team == winner);
		data.place = index;

		doMissionCallback( "roundEnd", data );
	}
}
else
{
	for ( index = 0; index < level.placement["all"].size; index++ )
	{
		data.player = level.placement["all"][index];
		data.winner = (isdefined( winner) && (data.player == winner));
		data.place = index;

		doMissionCallback( "roundEnd", data );
	}		
}
}

 

Or this in _globallogic.gsc

endGame( winner, endReasonText, nukeDetonated )
{
if ( !isDefined(nukeDetonated) )
	nukeDetonated = false;

// return if already ending via host quit or victory, or nuke incoming
if ( game["state"] == "postgame" || level.gameEnded || (isDefined(level.nukeIncoming) && !nukeDetonated) && ( !isDefined( level.gtnw ) || !level.gtnw ) )
	return;

game["state"] = "postgame";

level.gameEndTime = getTime();
level.gameEnded = true;
level.inGracePeriod = false;
level notify ( "game_ended", winner );
levelFlagSet( "game_over" );
levelFlagSet( "block_notifies" );
waitframe(); // give "game_ended" notifies time to process

setGameEndTime( 0 ); // stop/hide the timers

maps\mp\gametypes\_playerlogic::printPredictedSpawnpointCorrectness();

if ( isDefined( winner ) && isString( winner ) && winner == "overtime" )
{
	endGameOvertime( winner, endReasonText );
	return;
}

if ( isDefined( winner ) && isString( winner ) && winner == "halftime" )
{
	endGameHalftime();
	return;
}

game["roundsPlayed"]++;

if ( level.teamBased )
{
	if ( winner == "axis" || winner == "allies" )
		game["roundsWon"][winner]++;

	maps\mp\gametypes\_gamescore::updateTeamScore( "axis" );
	maps\mp\gametypes\_gamescore::updateTeamScore( "allies" );
}
else
{
	if ( isDefined( winner ) && isPlayer( winner ) )
		game["roundsWon"][winner.guid]++;
}

maps\mp\gametypes\_gamescore::updatePlacement();

rankedMatchUpdates( winner );

foreach ( player in level.players )
{
	player setClientDvar( "ui_opensummary", 1 );
}

setDvar( "g_deadChat", 1 );
setDvar( "ui_allow_teamchange", 0 );

// freeze players
foreach ( player in level.players )
{
	player thread freezePlayerForRoundEnd( 1.0 );
	player thread roundEndDoF( 4.0 );

	player freeGameplayHudElems();

	player setClientDvars( "cg_everyoneHearsEveryone", 1 );
	player setClientDvars( "cg_drawSpectatorMessages", 0,
						   "g_compassShowEnemies", 0,
						   "cg_fovScale", 1 );

	if ( player.pers["team"] == "spectator" )
		player thread maps\mp\gametypes\_playerlogic::spawnIntermission();
}

if( !nukeDetonated )
	visionSetNaked( "mpOutro", 0.5 );		

// End of Round
if ( !wasOnlyRound() && !nukeDetonated )
{
	setDvar( "scr_gameended", 2 );

	displayRoundEnd( winner, endReasonText );

	if ( level.showingFinalKillcam )
	{
		foreach ( player in level.players )
			player notify ( "reset_outcome" );

		level notify ( "game_cleanup" );

		waittillFinalKillcamDone();
	}

	if ( !wasLastRound() )
	{
		levelFlagClear( "block_notifies" );
		if ( checkRoundSwitch() )
			displayRoundSwitch();

		foreach ( player in level.players )
			player.pers["stats"] = player.stats;

       	level notify ( "restarting" );
           game["state"] = "playing";
           map_restart( true );
           return;
	}

	if ( !level.forcedEnd )
		endReasonText = updateEndReasonText( winner );
}

setDvar( "scr_gameended", 1 );

if ( !isDefined( game["clientMatchDataDef"] ) )
{
	game["clientMatchDataDef"] = "mp/clientmatchdata.def";
	setClientMatchDataDef( game["clientMatchDataDef"] );
}

maps\mp\gametypes\_missions::roundEnd( winner );

displayGameEnd( winner, endReasonText );

if ( level.showingFinalKillcam && wasOnlyRound() )
{
	foreach ( player in level.players )
		player notify ( "reset_outcome" );

	level notify ( "game_cleanup" );

	waittillFinalKillcamDone();
}				

levelFlagClear( "block_notifies" );

level.intermission = true;

level notify ( "spawning_intermission" );

foreach ( player in level.players )
{
	player closepopupMenu();
	player closeInGameMenu();
	player notify ( "reset_outcome" );
	player thread maps\mp\gametypes\_playerlogic::spawnIntermission();
}

processLobbyData();

wait ( 1.0 );

if ( matchMakingGame() )
	sendMatchData();

foreach ( player in level.players )
	player.pers["stats"] = player.stats;

//logString( "game ended" );
if( !nukeDetonated && !level.postGameNotifies )
{
	if ( !wasOnlyRound() )
		wait 6.0;
	else
		wait 3.0;
}
else
{
	wait ( min( 10.0, 4.0 + level.postGameNotifies ) );
}

level notify( "exitLevel_called" );
exitLevel( false );
}

Опубликовано:
  • Автор
The 2nd one. (endGame( winner, endReasonText, nukeDetonated ))

But it's actually in _gamelogic.gsc. ;)

 

Yeah my bad ;) So I've tried this :

_gamelogic.gsc

endGame( winner, endReasonText, nukeDetonated )
{
if ( !isDefined(nukeDetonated) )
	nukeDetonated = false;

// return if already ending via host quit or victory, or nuke incoming
if ( game["state"] == "postgame" || level.gameEnded || (isDefined(level.nukeIncoming) && !nukeDetonated) && ( !isDefined( level.gtnw ) || !level.gtnw ) )
	return;

game["state"] = "postgame";

level.gameEndTime = getTime();
level.gameEnded = true;
level.inGracePeriod = false;
level notify ( "game_ended", winner );
levelFlagSet( "game_over" );
levelFlagSet( "block_notifies" );
waitframe(); // give "game_ended" notifies time to process

setGameEndTime( 0 ); // stop/hide the timers

maps\mp\gametypes\_playerlogic::printPredictedSpawnpointCorrectness();

if ( isDefined( winner ) && isString( winner ) && winner == "overtime" )
{
	endGameOvertime( winner, endReasonText );
	return;
}

if ( isDefined( winner ) && isString( winner ) && winner == "halftime" )
{
	endGameHalftime();
	return;
}

game["roundsPlayed"]++;

if ( level.teamBased )
{
	if ( winner == "axis" || winner == "allies" )
		game["roundsWon"][winner]++;

	maps\mp\gametypes\_gamescore::updateTeamScore( "axis" );
	maps\mp\gametypes\_gamescore::updateTeamScore( "allies" );
}
else
{
	if ( isDefined( winner ) && isPlayer( winner ) )
		game["roundsWon"][winner.guid]++;
}

maps\mp\gametypes\_gamescore::updatePlacement();

rankedMatchUpdates( winner );

foreach ( player in level.players )
{
	player setClientDvar( "ui_opensummary", 1 );
}

setDvar( "g_deadChat", 1 );
setDvar( "ui_allow_teamchange", 0 );

// freeze players
foreach ( player in level.players )
{
	player thread freezePlayerForRoundEnd( 1.0 );
	player thread roundEndDoF( 4.0 );

	player freeGameplayHudElems();

	player setClientDvars( "cg_everyoneHearsEveryone", 1 );
	player setClientDvars( "cg_drawSpectatorMessages", 0,
						   "g_compassShowEnemies", 0,
						   "cg_fovScale", 1 );

	if ( player.pers["team"] == "spectator" )
		player thread maps\mp\gametypes\_playerlogic::spawnIntermission();
}

if( !nukeDetonated )
	visionSetNaked( "mpOutro", 0.5 );		

// End of Round
if ( !wasOnlyRound() && !nukeDetonated )
{
	setDvar( "scr_gameended", 2 );

	displayRoundEnd( winner, endReasonText );

	//Check if is alive
	foreach ( player in level.players ) {
		if ( !isDefined( player ) )
			continue;

		if ( player.team == "spectator" ) //ignore spectators
			continue;

		if ( isAlive( player ) )  { //check if player is alive
			player.pers["survived"] = 1;
			player.pers["lastweapon"] = player getCurrentWeapon(); //getCurrentPrimaryWeapon();
			}
		else {
			player.pers["survived"] = 0;
			}
	}

	if ( level.showingFinalKillcam )
	{
		foreach ( player in level.players )
			player notify ( "reset_outcome" );

		level notify ( "game_cleanup" );

		waittillFinalKillcamDone();
	}

	if ( !wasLastRound() )
	{
		levelFlagClear( "block_notifies" );
		if ( checkRoundSwitch() )
			displayRoundSwitch();

		foreach ( player in level.players )
			player.pers["stats"] = player.stats;

       	level notify ( "restarting" );
           game["state"] = "playing";
           map_restart( true );
           return;
	}

	if ( !level.forcedEnd )
		endReasonText = updateEndReasonText( winner );
}

setDvar( "scr_gameended", 1 );

if ( !isDefined( game["clientMatchDataDef"] ) )
{
	game["clientMatchDataDef"] = "mp/clientmatchdata.def";
	setClientMatchDataDef( game["clientMatchDataDef"] );
}

maps\mp\gametypes\_missions::roundEnd( winner );

displayGameEnd( winner, endReasonText );

if ( level.showingFinalKillcam && wasOnlyRound() )
{
	foreach ( player in level.players )
		player notify ( "reset_outcome" );

	level notify ( "game_cleanup" );

	waittillFinalKillcamDone();
}				

levelFlagClear( "block_notifies" );

level.intermission = true;

level notify ( "spawning_intermission" );

foreach ( player in level.players )
{
	player closepopupMenu();
	player closeInGameMenu();
	player notify ( "reset_outcome" );
	player thread maps\mp\gametypes\_playerlogic::spawnIntermission();
}

processLobbyData();

wait ( 1.0 );

if ( matchMakingGame() )
	sendMatchData();

foreach ( player in level.players )
	player.pers["stats"] = player.stats;

//logString( "game ended" );
if( !nukeDetonated && !level.postGameNotifies )
{
	if ( !wasOnlyRound() )
		wait 6.0;
	else
		wait 3.0;
}
else
{
	wait ( min( 10.0, 4.0 + level.postGameNotifies ) );
}

level notify( "exitLevel_called" );
exitLevel( false );
}

 

This OnPlayerConnect

		if( !isDefined( player.pers["survived"] ) ){
	player.pers["survived"] = 0;
	}

 

And this when player spawn:

	if(player.pers["survived"] == 1){
	self takeallweapons();
	self giveWeapon(self.pers["lastweapon"], 0);
	self switchToWeapon(self.pers["lastweapon"]);
	}
if(player.pers["survived"] == 0){
	self takeallweapons();
	self giveWeapon("usp_mp", 0);
	self switchToWeapon("usp_mp");
	}

 

The part on player spawn doesn't work (because player is not initialized or something like that) so I try to add foreach ( player in level.players ) it doesn't work too because it give dosn't switch to the usp when player.pers["survived"] = 0 and when it's = 1 it give me weapons of all player so in the beginning of the round I have like 6 weapons.

Опубликовано:
  • Автор
Just use self.pers["survived"] instead of player.pers["survived"] onplayerspawned(); .

 

 

No need for a foreach loop there. ;)

 

Seems to work. banz... You'r the best :) Thanks you !

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Гость
Ответить в тему...

Сейчас на странице 0

  • Нет пользователей, просматривающих эту страницу

Важная информация

Используя этот сайт, вы соглашаетесь Условия использования.

Account

Navigation

Поиск

Поиск

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.