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

Members Online

»
0 Active | 7 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
Previous Page
subscribe
Author Topic: scripting help
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:21 pm
Something like this should work to get you started on the first step. In war.gsc add a new function:

Code:
chooseTaggedPlayer()
{
    level waittill("prematch_over");
    allPlayers = level.players;
    level.taggedPlayer = allPlayers[ randomInt(allPlayers.size) ];
    iprintln ("tag " + level.taggedPlayer + ", your it!");

}


In the onStartGameType function in war.gsc add 'level thread chooseTaggedPlayer();' at the bottom. The thread will wait until the ready up period is over but before the game starts, chooses a random player, and prints the name to the screen.

Share |
damo56
General Member
Since: May 29, 2009
Posts: 29
Last: Aug 20, 2010
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Wednesday, May. 19, 2010 12:06 pm
ok thanks for that. got it working. how would i write an if statement that goes along the lines of

if on axis team
do the following.

ive looked everywhere but nothing works (ive got my script compile error down to the if statement in my code.)
Share |
Pedro699
General Member
Since: Jun 19, 2006
Posts: 781
Last: Dec 18, 2010
[view latest posts]
Level 7
Category: CoD4 Scripting
Posted: Wednesday, May. 19, 2010 01:54 pm
Code:
if(player.pers["team"] == "axis")
{
  // Do something
}
Share |
Samuel033
General Member
Since: Dec 10, 2009
Posts: 484
Last: Dec 25, 2015
[view latest posts]
Level 5
Category: CoD4 Scripting
Posted: Wednesday, May. 19, 2010 05:24 pm
Just to add, if you are running a check on every player in a global function like the 'tagged player' check at the beginning of a round you get all players like above, get their size and run a loop checking each player.

Code:
allPlayers = level.players;
for(i=0; i < allPlayers.size; i++)
{
    if(allPlayers[i].pers["team"] == "axis")
        //do something
}
Share |
damo56
General Member
Since: May 29, 2009
Posts: 29
Last: Aug 20, 2010
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Thursday, May. 20, 2010 06:06 am
ok ty i think thats all i need, i can see where i stuffed up. thanks samuel and pedro for the help its much appreciated

edited on May. 20, 2010 02:08 am by damo56

and thanks for the other code samuel :P
Share |
Samuel033
General Member
Since: Dec 10, 2009
Posts: 484
Last: Dec 25, 2015
[view latest posts]
Level 5
Category: CoD4 Scripting
Posted: Thursday, May. 20, 2010 04:46 pm
Good luck. When you get it working post a vid on xfire. [biggrin]
Share |
Restricted Access Topic is Locked
Page
Previous 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

»