NinjaWa

Help with Deathrun mod.

Recommended Posts

Hello guys, I'm NinjaWa, I have my own deathrun server, hosted thanks to Xenia Community.

As I'm getting bored at school with subjects and I'm getting a bit bored of Promod and sometimes deathrun, I would like to help other people with deathrun mod or any other mod (I can try).

So if any of you need something or have any question you can simply post your question or request here and I will try to do it.

Anything, .menu's, .gsc's, .csv, anything you need :)

Greez,

NinjaWa. :P

Share this post


Link to post
Share on other sites

Hi, so I'm trying to script my own DR plugin and this is what I have so far:


init( modVersion )
{

precacheItem( "colt44_mp" );
thread onPlayerSpawn();

}

onPlayerSpawn()
{
for(;
{
level waittill( "player_spawn", player );
player iprintln("^1IS THIS WORKING??????");
}
}

I'm using NFOServers to host my CoD4 DR server and I'm trying to figure out what the f*** is wrong this this, I try to launch the server and it crashes or something.

Please help me! :)

Best regards,

Krazi.

NOTE: Nevermind, I've fixed it.. Simple issue with renaming the file, etc.. Thanks for this thread though!

Share this post


Link to post
Share on other sites

Okay, it's Krazi again!

So I'm trying to make a plugin that spawns the player a weapon, I've got that down but I want to be able to detect the current user's weapon and replace it with the one I want them to have.

Like this:


if(!player hasWeapon(weapon))
{
player giveWeapon(weapon);
player giveMaxAmmo(weapon);
player switchToWeapon(weapon);
}

Any ideas? Thanks.

Best regards,

Krazi.

Share this post


Link to post
Share on other sites
what's .menu?

Hi Lossy, .menu files are files that are executed ingame and them are used to get on a menu, don't confuse them with .inc files.

what are .inc files and could you explain a bit more on the menu part

Share this post


Link to post
Share on other sites
Okay, it's Krazi again!

So I'm trying to make a plugin that spawns the player a weapon, I've got that down but I want to be able to detect the current user's weapon and replace it with the one I want them to have.

Like this:


if(!player hasWeapon(weapon))
{
player giveWeapon(weapon);
player giveMaxAmmo(weapon);
player switchToWeapon(weapon);
}

Any ideas? Thanks.

Best regards,

Krazi.

Hi Krazi, theres something inside _mod.gsc, search for this (not on MakeMeHuman()):

​self giveWeapon( self.pers["weapon"] );

There you will see some code lines, in my mod I want everybody to have their selected weapon and as a secondary, to have a knife, this is my code:

​    self giveWeapon( self.pers["weapon"] );
self setSpawnWeapon( self.pers["weapon"] );
self giveWeapon( "knife_mp" );
self giveMaxAmmo( self.pers["weapon"] );

So in your case, you will need to delete that "self.pers["weapon"]" and replace it with the weapon name, use a format like this:

self giveWeapon( "name of your weapon" );​
self giveMaxAmmo( "name of your weapon" );

So no need of creating unnecessary plugins and with the plugin you wanted to do, everytime someone gets that weapon, it will be replaced with the one you want, means you will only have one gun.

Share this post


Link to post
Share on other sites
what's .menu?

Hi Lossy, .menu files are files that are executed ingame and them are used to get on a menu, don't confuse them with .inc files.

what are .inc files and could you explain a bit more on the menu part

Well, .inc files are the ones that can be included inside a .menu file using this format:

​#include "directory here"

But, we can use .inc or any extension we want I think (never tried to so, I'm not sure).

.menu files are simple code that cod4 engine use to make the menus, it's like a .gsc file but for menus and coded other way.

(I don't really know how to explain it better, could you explain me because I know you and I know you are very good with what you do ;) ).

Greez,

NinjaWa.

Share this post


Link to post
Share on other sites
Okay, it's Krazi again!

So I'm trying to make a plugin that spawns the player a weapon, I've got that down but I want to be able to detect the current user's weapon and replace it with the one I want them to have.

Like this:


if(!player hasWeapon(weapon))
{
player giveWeapon(weapon);
player giveMaxAmmo(weapon);
player switchToWeapon(weapon);
}

Any ideas? Thanks.

Best regards,

Krazi.

Hi Krazi, theres something inside _mod.gsc, search for this (not on MakeMeHuman()):

​self giveWeapon( self.pers["weapon"] );

There you will see some code lines, in my mod I want everybody to have their selected weapon and as a secondary, to have a knife, this is my code:

​    self giveWeapon( self.pers["weapon"] );
self setSpawnWeapon( self.pers["weapon"] );
self giveWeapon( "knife_mp" );
self giveMaxAmmo( self.pers["weapon"] );

So in your case, you will need to delete that "self.pers["weapon"]" and replace it with the weapon name, use a format like this:

self giveWeapon( "name of your weapon" );​
self giveMaxAmmo( "name of your weapon" );

So no need of creating unnecessary plugins and with the plugin you wanted to do, everytime someone gets that weapon, it will be replaced with the one you want, means you will only have one gun.

Okay, so I've done that but i'm trying to make it where when the player dies and respawns, his weapons are givin back. The ones I set anyway.

Share this post


Link to post
Share on other sites
Okay, it's Krazi again!

So I'm trying to make a plugin that spawns the player a weapon, I've got that down but I want to be able to detect the current user's weapon and replace it with the one I want them to have.

Like this:


if(!player hasWeapon(weapon))
{
player giveWeapon(weapon);
player giveMaxAmmo(weapon);
player switchToWeapon(weapon);
}

Any ideas? Thanks.

Best regards,

Krazi.

Hi Krazi, theres something inside _mod.gsc, search for this (not on MakeMeHuman()):

​self giveWeapon( self.pers["weapon"] );

There you will see some code lines, in my mod I want everybody to have their selected weapon and as a secondary, to have a knife, this is my code:

​    self giveWeapon( self.pers["weapon"] );
self setSpawnWeapon( self.pers["weapon"] );
self giveWeapon( "knife_mp" );
self giveMaxAmmo( self.pers["weapon"] );

So in your case, you will need to delete that "self.pers["weapon"]" and replace it with the weapon name, use a format like this:

self giveWeapon( "name of your weapon" );​
self giveMaxAmmo( "name of your weapon" );

So no need of creating unnecessary plugins and with the plugin you wanted to do, everytime someone gets that weapon, it will be replaced with the one you want, means you will only have one gun.

Okay, so I've done that but i'm trying to make it where when the player dies and respawns, his weapons are givin back. The ones I set anyway.

Ok, do you have ghostrun? If you have it, attach it here as I don't have it and never use it on my server.

I don't know if you want to do it when you have ghostrun as it is a bit different if you have it...

Share this post


Link to post
Share on other sites

Ok, then you will need to do this:

​if( level.player HasWeapon( "weaponnamehere:D" ) )
{
self takeallweapons(); // If you want to remove the weapons
self GiveWeapon("weaponname_mp");
player giveMaxAmmo("weaponname_mp");
self switchtoweapon("weaponname_mp");
}

Share this post


Link to post
Share on other sites
Ok, then you will need to do this:

if( level.player HasWeapon( "weaponnamehere:D" ) )
{
self takeallweapons(); // If you want to remove the weapons
self GiveWeapon("weaponname_mp");
player giveMaxAmmo("weaponname_mp");
self switchtoweapon("weaponname_mp");
}

Ahhh, level.player. I was doing if(player hasWeapon( "" ){}

I'll try it out!

EDIT: In free-mode when they respawn, the weapon disappears, I wanted it to spawn everytime. I have NO clue how to do this now, I don't even know if it's possible anymore.

Share this post


Link to post
Share on other sites

Sorry, I couldn't reply yesterday, you should use something like this then:

​if( level.player HasWeapon( "weaponnamehere:D" ) )
{
self takeallweapons(); // If you want to remove the weapons
self GiveWeapon("weaponname_mp");
player giveMaxAmmo("weaponname_mp");
self switchtoweapon("weaponname_mp");
}
if( level.freeRun )
wait 0.1;
level waittill( "player_killed" );
wait 0.1;
level waittill( self isReallyAlive() );
{
self takeallweapons(); // If you want to remove the weapons
self GiveWeapon("weaponname_mp");
player giveMaxAmmo("weaponname_mp");
self switchtoweapon("weaponname_mp");
wait 0.1;
}

I DIDN'T test it so there probably will be some bug but I don't know.

Everything is possible, if you spend time on it, if you do everything for it, you will finally get it, think of every action the player needs to do and of course, the orders, that's very important :)

Share this post


Link to post
Share on other sites

Where is level.player defined? the reason krazi script didn't work is because he had ! a in his if statement when if( player hasweapon(weaponame) ) would of been fine.

Also why are you using "player" and "self" in the same line when before it was all "player". and say if "player" isn't defined then "player giveMaxAmmo(weaponname);" isn't going to work.

Also if you want to detect when a player respawns in deathrun you can do waittill( "spawned_player" );

e.g


detectWeapon()
{
self endon("disconnect");
for(;
{

self waitTill("spawned_player");

if( self hasWeapon("weaponame_mp") )
{
self takeAllWeapons();
self giveWeapon("weaponname_mp");
self giveMaxAmmo("weaponname_mp");
self switchtoweapon("weaponname_mp");
}
}
}

Share this post


Link to post
Share on other sites
Where is level.player defined? the reason krazi script didn't work is because he had ! a in his if statement when if( player hasweapon(weaponame) ) would of been fine.

Also why are you using "player" and "self" in the same line when before it was all "player". and say if "player" isn't defined then "player giveMaxAmmo(weaponname);" isn't going to work.

Also if you want to detect when a player respawns in deathrun you can do waittill( "spawned_player" );

e.g


detectWeapon()
{
self endon("disconnect");
for(;
{

self waitTill("spawned_player");

if( self hasWeapon("weaponame_mp") )
{
self takeAllWeapons();
self giveWeapon("weaponname_mp");
self giveMaxAmmo("weaponname_mp");
self switchtoweapon("weaponname_mp");
}
}
}

My fault, you are right.

Share this post


Link to post
Share on other sites
Where is level.player defined? the reason krazi script didn't work is because he had ! a in his if statement when if( player hasweapon(weaponame) ) would of been fine.

Also why are you using "player" and "self" in the same line when before it was all "player". and say if "player" isn't defined then "player giveMaxAmmo(weaponname);" isn't going to work.

Also if you want to detect when a player respawns in deathrun you can do waittill( "spawned_player" );

e.g


detectWeapon()
{
self endon("disconnect");
for(;
{

self waitTill("spawned_player");

if( self hasWeapon("weaponame_mp") )
{
self takeAllWeapons();
self giveWeapon("weaponname_mp");
self giveMaxAmmo("weaponname_mp");
self switchtoweapon("weaponname_mp");
}
}
}

I supplied one patch of code, I've defined the player in:

level waittill("player_spawn", player);

Is this not correct?

EDIT: As I'm new to this coding language and I want to progress, I have one question which is probably self-explanatory. But

self endon("disconnect");

waits for the server to disconnect or player, and why put self there? Sorry if this questions is stupid..

Share this post


Link to post
Share on other sites

Self = player entity by default in CoD4.

Self waittill will happen when a player activates event, level is when anything activates the event i believe as it's a global trigger.

The endon there so the script stops looping. If a script continues to loop when a player not there it willl give of errors such as "undefined" which means it can't find who "self" is in this case because he has left. So yes this will end the script when player disconnects if the code has been activated.

It also helps you end scripts on certain events e.g if you have something following a player but you don't want it to follow him when he dies or join spectators you'd add endon ("death"); or endon ("joined_spectators"); or you can do both to be sure. You can find these events like "death", "disconnect", "spawned" etc.. in the mod.ff or for stock cod4 you'd find them in the globallogic.gsc.

More info: http://wiki.modsrepository.com/index.php?title=Notify_/_Endon_/_Waittill

If you want to get into a read coding language GSC isn't really the best option since it's more of a game script language not a proper language like python, java, C/C++ etc..

Share this post


Link to post
Share on other sites

Well, I wasn't wrong, I tried my script changing that "player" thingy and it worked...

You put self if you didn't define something else like player or who or whatever you want, it will apply to a player.

as the name says end on disconnect of the player :P

Share this post


Link to post
Share on other sites

OH! Maybe it's because it keeps looping and doesn't endon("death"); lol.. Thanks, I'll try this one out.

~EDIT~

Okay, so when I do this:


onPlayerSpawn()
{
for(;
{
self endon("disconnect");
level waittill("spawn_player", player);

player takeAllWeapons();
player giveWeapon("colt44_mp");
player giveMaxAmmo("colt44_mp");
player switchToWeapon("colt44_mp");
}
}

Nothing happens, and when I do this:


onPlayerSpawn()
{
for(;
{
self endon("disconnect");
self waittill("spawned_player");

self takeAllWeapons();
self giveWeapon("colt44_mp");
self giveMaxAmmo("colt44_mp");
self switchToWeapon("colt44_mp");
}
}

My server crashes.

~EDIT 2~

Also, is it self waittill("spawned_player"); or self waittill("spawn_player");

Share this post


Link to post
Share on other sites

It's self waittill("player_spawn");

Can you try using this: (put this after the waittill)

if( self isReallyAlive())

{

self takeAllWeapons();

self giveWeapon("colt44_mp");

self giveMaxAmmo("colt44_mp");

self switchToWeapon("colt44_mp");

}

Edited: I posted the code.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.