Page 1 of 1
small gametype/mod question/problem
Posted: December 14th, 2006, 4:27 pm
by creator
im trying to make a small mod that will explode people when they die,
i made these folders:
maps/mp/gametypes/explode.gsc
there isnt a error but it aint working.
Code: Select all
main()
{
thread testfield();
}
testfield()
{
origin = self getorigin();
range = 300;
maxdamage = 2000;
mindamage = 50;
if(user.health > 1)
playfx ( level._effect["mine_explosion"], origin);
}
}
can anyone tell me why? and if im doing it wrong pls tell me what im doing wrong
creator
Posted: December 14th, 2006, 5:04 pm
by steveuk
If ya get it working let me know so a can send me a copy, this sound fun and intresting..
SteveUK

Posted: December 14th, 2006, 5:44 pm
by creator
will do

if.. i ever get it to work

Posted: December 15th, 2006, 3:03 pm
by Drofder2004
where have you threaded the script from?
Posted: December 15th, 2006, 5:38 pm
by creator
what u mean? and new script is:
Code: Select all
main()
{
maps\mp\_load::main();
level._effect["mine_explosion"] = loadfx ("fx/impacts/newimps/minefield.efx");
thread testfield();
}
testfield()
origin = self getorigin();
{
if(user.health <= 1)
iprintlnbold("^2Working");
playfx ( level._effect["mine_explosion"], origin);
}
}
but still not working
Posted: December 15th, 2006, 7:26 pm
by Drofder2004
Code: Select all
main()
{
maps\mp\_load::main();
level._effect["mine_explosion"] = loadfx ("fx/impacts/newimps/minefield.efx");
thread testfield();
}
testfield()
{
players = getentarray("players","targetname");
for(i=0;i<players.size;i++)
{
players[i] thread healthcheck();
}
}
healthcheck()
{
while(1)
{
if(self.health <= 1)
{
iprintlnbold("^2Working");
playfx ( level._effect["mine_explosion"], self.origin);
wait 5;
}
wait 0.05;
}
}
Posted: December 15th, 2006, 11:45 pm
by creator
tested it but wont work and i cant see the green text,
but i can only test if i /kill or kill my self with nade will it only work if other kills other guy?
Posted: December 17th, 2006, 1:56 am
by creator
do i maybe need to change dm/sd and other .gsc's and add it to my pk3 to make it work?
cause i saw alot of mods who do this.
and if yes wot i need to add?
Posted: December 17th, 2006, 3:21 am
by Drofder2004
Is this a map gsc or a mod gsc?
If its a map, this sorta thing will be hard to do, if its a mod (ie, it goes into DM/SD etc then it will be easier).
Posted: December 17th, 2006, 2:51 pm
by creator
its a mod, so how do i need to insert it and where?
Posted: December 17th, 2006, 5:01 pm
by Drofder2004
Ok, we can use a method were we take over a thread.
Basically, inside all gametypes, there is a thread called "Callback_PlayerKilled", this is also referenced by the variable 'level.callbackPlayerKilled'.
what we want to do is take over this callback and use our own...
First create the following code inside mymod.gsc (if you want a different name, you will need to change all instances of 'mymod'). This will be used to call our own version of the playerKilled thread...
myMod.gsc
Code: Select all
playerKilled(eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration)
{
self endon ("disconnect");
//Now we need to call the original thread first, to play all the death animations and register the death.
[[level.default_CallbackPlayerKilled]](eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration);
//Now for our code
playFx(level._effect["mine_explosion"], self.origin);
// Because this thread was called on the player who died, we do not need any thing but the FX.
}
So that is how to take over the function, but first we need to thread this in EVERY gametype.
First open dm.gsc
Scroll down until you find
Code: Select all
level.callbackStartGameType = ::Callback_StartGameType;
level.callbackPlayerConnect = ::Callback_PlayerConnect;
level.callbackPlayerDisconnect = ::Callback_PlayerDisconnect;
level.callbackPlayerDamage = ::Callback_PlayerDamage;
level.callbackPlayerKilled = ::Callback_PlayerKilled;
maps\mp\gametypes\_callbacksetup::SetupCallbacks();
Now straight after this line you will need to add the first code we created... you need to change the level.callbackPlayerKilled.
It is very important that it comes after the "_callbacksetup::SetupCallback();" part, as this is the part that is created to save all the default callbacks
So, add this code...
Code: Select all
level.callbackPlayerKilled = mymod::playerKilled;
You should now have....
Code: Select all
level.callbackStartGameType = ::Callback_StartGameType;
level.callbackPlayerConnect = ::Callback_PlayerConnect;
level.callbackPlayerDisconnect = ::Callback_PlayerDisconnect;
level.callbackPlayerDamage = ::Callback_PlayerDamage;
level.callbackPlayerKilled = ::Callback_PlayerKilled;
maps\mp\gametypes\_callbacksetup::SetupCallbacks();
level.callbackPlayerKilled = mymod::playerKilled;
Give me any errors you get....
Becareful copying this code, the forum width is small and some things have gone down a line but should be 1 full line
Posted: December 17th, 2006, 7:02 pm
by creator
ok im a little confused,
is this good?
[dm.gsc]
Code: Select all
level.callbackStartGameType = ::Callback_StartGameType;
level.callbackPlayerConnect = ::Callback_PlayerConnect;
level.callbackPlayerDisconnect = ::Callback_PlayerDisconnect;
level.callbackPlayerDamage = ::Callback_PlayerDamage;
level.callbackPlayerKilled = ::Callback_PlayerKilled;
maps\mp\gametypes\_callbacksetup::SetupCallbacks();
playerKilled(eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration)
{
self endon ("disconnect");
//Now we need to call the original thread first, to play all the death animations and register the death.
[[level.default_CallbackPlayerKilled]](eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration);
//Now for our code
playFx(level._effect["mine_explosion"], self.origin);
// Because this thread was called on the player who died, we do not need any thing but the FX.
}
level.callbackPlayerKilled = explode::playerKilled;
[explode.gsc]
Code: Select all
playerKilled(eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration)
{
self endon ("disconnect");
//Now we need to call the original thread first, to play all the death animations and register the death.
[[level.default_CallbackPlayerKilled]](eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration);
//Now for our code
playFx(level._effect["mine_explosion"], self.origin);
// Because this thread was called on the player who died, we do not need any thing but the FX.
}
if not can u please change it?
Posted: December 18th, 2006, 12:50 am
by Drofder2004
I'm not sure what you have done?
In your first code box you have...
Code: Select all
level.callbackStartGameType = ::Callback_StartGameType;
level.callbackPlayerConnect = ::Callback_PlayerConnect;
level.callbackPlayerDisconnect = ::Callback_PlayerDisconnect;
level.callbackPlayerDamage = ::Callback_PlayerDamage;
level.callbackPlayerKilled = ::Callback_PlayerKilled;
maps\mp\gametypes\_callbacksetup::SetupCallbacks();
playerKilled(eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration)
{
self endon ("disconnect");
//Now we need to call the original thread first, to play all the death animations and register the death.
[[level.default_CallbackPlayerKilled]](eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration);
//Now for our code
playFx(level._effect["mine_explosion"], self.origin);
// Because this thread was called on the player who died, we do not need any thing but the FX.
}
level.callbackPlayerKilled = explode::playerKilled;
What is all that in there for?
All that you change in dm.gsc is the single line...
Code: Select all
level.callbackStartGameType = ::Callback_StartGameType;
level.callbackPlayerConnect = ::Callback_PlayerConnect;
level.callbackPlayerDisconnect = ::Callback_PlayerDisconnect;
level.callbackPlayerDamage = ::Callback_PlayerDamage;
level.callbackPlayerKilled = ::Callback_PlayerKilled;
maps\mp\gametypes\_callbacksetup::SetupCallbacks();
level.callbackPlayerKilled = mymod::playerKilled; // This is the only thing added!
Then in your seperate file.
Code: Select all
playerKilled(eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration)
{
self endon ("disconnect");
//Now we need to call the original thread first, to play all the death animations and register the death.
[[level.default_CallbackPlayerKilled]](eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration);
//Now for our code
playFx(level._effect["mine_explosion"], self.origin);
// Because this thread was called on the player who died, we do not need any thing but the FX.
}
The second file must be placed inside the gametypes folder with the dm.gsc
Posted: December 18th, 2006, 4:15 pm
by creator
ow oke

gonna test in a second
should the fx also play when i kill my self?
Posted: December 18th, 2006, 4:24 pm
by creator
i tested but no errors or fx be showed...
here is the link to download it.
http://www.creator-mapper.com/downloads/explode.pk3 press here
cod1