Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 8 Guests
Online:

LATEST FORUM THREADS

»
warfare
CoD4 Map + Mod Releases
Voting menu on maps
CoD+UO General
Hauling 911
CoDBO3 General

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 4
Category: CoD4 Scripting
Scripting and coding with Call of Duty 4.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername, novemberdobby
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked
Page
Next Page
subscribe
Author Topic: scripting help
damo56
General Member
Since: May 29, 2009
Posts: 29
Last: Aug 20, 2010
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Sunday, May. 16, 2010 12:05 pm
im a bit of a noob at scripting and i have an issue with the following script

main()
{
self endon( "disconnect" );
for(;;)
{
self takeAllWeapons();
self ClearPerks();
if( self.pers["team"] == "allies" )
thread axis();
}
}

axis()
{
self giveWeapon("c4_mp");
wait 0.5
self SwitchToWeapon("c4_mp")
}


it is called from weapons();

main()
{
thread setupDvars();
thread autobalanceWarning();
thread weapons();
}

setupDvars()
{
setDvar("jump_slowdownEnable","0");
setDvar("bg_fallDamageMaxHeight","1000");
setDvar("bg_fallDamageMinHeight","1000");
}

autobalanceWarning()
{
if(getdvar("scr_teambalance") == "1")
for(;;)
{
level waittill("connected", player);
player thread tag_scripts\autobalancespam::spam();
}
}

weapons()
{
if(getdvar("scr_teambalance") == "0")
for(;;)
{
level waittill("connected", player);
player thread tag_scripts\tag_weapons::main();
}
}

when i take out the weapons script everything works perfect. its probally obvious but as i said i really dont know too much
Share |
tomv8
General Member
Since: Oct 5, 2008
Posts: 469
Last: Jul 14, 2010
[view latest posts]
Level 5
Category: CoD4 Scripting
Posted: Sunday, May. 16, 2010 02:39 pm
whats the issue?
Share |
Xylozi
General Member
Since: Jul 12, 2008
Posts: 218
Last: Mar 1, 2012
[view latest posts]
Level 4
Im a fan of MODSonair
Category: CoD4 Scripting
Posted: Sunday, May. 16, 2010 03:35 pm
Also what is this for; a mod or a map?
Share |
damo56
General Member
Since: May 29, 2009
Posts: 29
Last: Aug 20, 2010
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Sunday, May. 16, 2010 10:23 pm
its a mod. what its meant to do is take all weapons and perks then if theyre on the axis team also give them c4. sorry bout the lack of detail in previous post :P
Share |
Samuel033
General Member
Since: Dec 10, 2009
Posts: 484
Last: Dec 25, 2015
[view latest posts]
Level 5
Category: CoD4 Scripting
Posted: Monday, May. 17, 2010 06:27 am
Perhaps I am reading it wrong but it looks like the 'main' function that takes the perks and gives the c4 has nothing to stop it. So its constantly taking all weapons and giving the c4. Then taking it back again. Since it should only be done once on the player connecting take it out of the loop so it can return to the calling function. I am not at my computer with COD4 installed so I cant check it.

In any case, why are you taking all weapons and perks? In your code the only players to have anything are the axis. Is your goal to have c4 only allowed for axis but everything else is available to both teams?
Share |
damo56
General Member
Since: May 29, 2009
Posts: 29
Last: Aug 20, 2010
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Monday, May. 17, 2010 08:28 am
ok ill give some detail on the mod. the mod is going to be called c4 tag. it is sort of based on tag as you would play as a kid, except you kill with c4 and the person who dies becomes the tagger. we were also thinking of doing something like zombies where you kill everyone and they swap to axis and at the end of the round it restarts until the game time runs out.

the allied team have no weapons except their knife. they must run from the axis players with special abilities like high jumping/fast running etc.
Share |
Samuel033
General Member
Since: Dec 10, 2009
Posts: 484
Last: Dec 25, 2015
[view latest posts]
Level 5
Category: CoD4 Scripting
Posted: Tuesday, May. 18, 2010 12:05 am
It sounds like the kind of thing you do in class.gsc to control player loadout.

I suppose one way to do it is by default shut off all weapons and perks in the config. However for the knife to work there must be at least one weapon since there is no stand alone knife afaik. But I could be wrong about that. In which case you could give a pistol but take away all ammo.

When the level loads create a level variable called taggedEntity or something like that which refers to the current tagged player. At first it will be undefined. After the ready up period but before the game starts choose one at random.

this is all pseudo code only and just a guide

Code:
//in global logic and called only once.
tagStarter()
{
    waittill ("players ready"); //note: I dont remember what the exact name is.... just an example
    allPlayers = level.players;
    numPlayers = allPlayers.size;
    level.taggedEntity = allPlayers[ randomInt(numPlayers) ];
}


Create another thread in a loop in 'class' or 'weapons' for each player that waits for the players death. When that happens call taggedEntity takeweapon("c4") so the current tagged player no longer has it. Then set taggedEntity = self and self giveweapon("c4");

Code:
taggedEntityWatcher()
{
    for(;;)
    {
        self waittill("death");
        level.taggedEntity takeWeapon("c4");
        self giveWeapon("c4");
        level.taggedEntity = self.
    }
}


There are other ways to do this certainly and you might want to explore making the first function in war.gsc for that particular game type only so you can switch to normal S&D.
Share |
damo56
General Member
Since: May 29, 2009
Posts: 29
Last: Aug 20, 2010
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Tuesday, May. 18, 2010 02:46 am
ty ill give it a go and tell you what happens
Share |
Samuel033
General Member
Since: Dec 10, 2009
Posts: 484
Last: Dec 25, 2015
[view latest posts]
Level 5
Category: CoD4 Scripting
Posted: Tuesday, May. 18, 2010 06:27 am
To take care of the knife problem you might want to consider making the pistol a stun weapon of sorts with 3 shots. The method that comes to mind is to add a check in the playerdamage callback in 'global logic' that performs a short freeze function instead of checking for damage. However if you try the war.gsc route there might be a damage function there instead.

First check if the damaged entity is the tagged player in callback_playerDamage(various variables)

Code:
If(eAttacker == taggedEntity) //inflictor causes the damage.
{
    taggedEntity freezecontrols (true);
    wait 2;
    taggedEntity freezeControls(false);
    return; //Do no check for damage.

}

If the damaged entity is not the tagged player it must be one of the others and the function will check for c4 damage normally nor will other players be stunned.
Share |
damo56
General Member
Since: May 29, 2009
Posts: 29
Last: Aug 20, 2010
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Tuesday, May. 18, 2010 01:27 pm
ok, sorry but im a little bit confused with all this. as i said im a bit of a scripting noob. can you please explain it a bit more. ty
Share |
Restricted Access Topic is Locked
Page
Next Page
subscribe
MODSonline.com Forums : Call of Duty 4 : CoD4 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»