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

Members Online

»
0 Active | 269 Guests
Online:

LATEST FORUM THREADS

»
New BF2 Mod
BF2 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 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked
Page
Next Page
subscribe
Author Topic: Give Money... My script does not work...
loss23
General Member
Since: Jan 11, 2012
Posts: 7
Last: Jan 17, 2012
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Friday, Jan. 13, 2012 08:10 am
Hi,

I have a problem. I have script on Give Money. Script does not work :( Please help me .

Script:

Code:
		if(response == "G25")
		{
                        if(self.money >= 25)
                        {
                        	players = getentarray("player", "classname");
                        	for(x=0;x < players.size;x++)

                        	if(self islookingat(players[x]))

                        	self.spent +=50;
                        	players[x].spent -=50;
                        	players = players[x]; 
				}
                        	if(isDefined(players))
                        	{
                        	self iprintlnbold("^7Yo^9u ^7Tran^9sfer ^7mon^9ey^1!" + self.name);
                        	}
                        	else
                        	{
                        	self iprintlnbold("^1'^7Move the target on the current who want to transfer money^1!");
                        	}
			if(self.money < 25)
			{
				self iprintlnbold("^1'^7You do not have enough money^1!");
			}
		}
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Friday, Jan. 13, 2012 08:37 am
1. post the error you are getting
2. fix your tabs
3. fix the random use of { and } to be not random
4. post results
Share |
loss23
General Member
Since: Jan 11, 2012
Posts: 7
Last: Jan 17, 2012
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Friday, Jan. 13, 2012 09:18 am
Ehh please correct my script
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Friday, Jan. 13, 2012 10:36 am
it is just a thousand times easier when i know the error. also, you might learn some debugging yourself in the process :)

type developer 1 in the console of the server to properly display error messages.
Share |
Dobriy
General Member
Since: Mar 31, 2011
Posts: 96
Last: May 23, 2012
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Friday, Jan. 13, 2012 01:10 pm
loss23 How much time have you spent to do it yourself? Maybe try yourself before you flick other brain?
Share |
loss23
General Member
Since: Jan 11, 2012
Posts: 7
Last: Jan 17, 2012
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Friday, Jan. 13, 2012 01:21 pm
Heheheh :( No :D

Please :D I no have time ...:(
Share |
scillman
General Member
Since: Nov 23, 2006
Posts: 360
Last: Sep 1, 2012
[view latest posts]
Level 5
Category: CoD2 Scripting
Posted: Friday, Jan. 13, 2012 01:32 pm
Tips:
1. Try to learn code standards (i, size, thread, endon, etc.)
2. Use proper indents (tabs/spaces to the left of the lines)
3. Be sure to use '{' and '}' it makes your code better readable.
4. Time = patience. Patience = good. Good works.

This is not tested code! (Used to CoD4 :P)

Code:
init()
{
    preCacheString(&"MOD_MONEY_TRANSFER");      // You transfered money to &&1!
    preCacheString(&"MOD_MONEY_CHOOSE_TARGET"); // Change transfer target!
    preCacheString(&"MOD_MONEY_MISSING");       // You do not have enough money!

    level thread onPlayerConnect();
}

onPlayerConnect()
{
    for (;;)
    {
        level waittill("connected", player);

        // Make sure money is defined on a player when it connected.
        player.money = 0;
    }
}

handleResponse(response)
{
    self endon("disconnect");

    if (response == "G25")
    {
        if (self.money >= 25)
        {
            players = getEntArray("player", "classname");
            for (i = 0; i < players.size; i++) // Prefer 'i' for this kind of loops.
            {
                if (islookingat(players[i]))
                {
                    self.spent = += 50;
                    players[i].spent -= 50;
                    // players = players[i]; // Your loop should crash!
                }

                if (isDefined(players))
                {
                    self iPrintLnBold(&"MOD_MONEY_TRANSFER", self.name);
                }
                else
                {
                    self iPrintLnBold(&"MOD_MONEY_CHOOSE_TARGET");
                }
            }
        }
        else
        {
            self iPrintLnBold(&"MOD_MONEY_MISSING");
        }
    }
}

islookingat(player)
{
    // Do something...
    return false; // In case your forget >.<
}
Share |
BraX
General Member
Since: Apr 29, 2008
Posts: 413
Last: May 26, 2012
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Friday, Jan. 13, 2012 01:57 pm
loss23 writes...
Quote:
Heheheh :( No :D

Please :D I no have time ...:(

I don't really care you don't have time, we aren't here to make it for you.

@scillman
isLookingAt( ) is buit-in function and works only with trigger_lookat entities.
Share |
liltc64
General Member
Since: Feb 12, 2007
Posts: 906
Last: Oct 22, 2012
[view latest posts]
Level 7
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Friday, Jan. 13, 2012 02:07 pm
loss23 writes...
Quote:
Heheheh :( No :D

Please :D I no have time ...:(


LOL! [duh] im doneeeeee and were suppose to make time to make a script for you that you dont even understand or even care to learn because you dont have time? [lol] [moon] im soooo done.
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Friday, Jan. 13, 2012 02:22 pm
liltc64 writes...
Quote:
loss23 writes...
Quote:
Heheheh :( No :D

Please :D I no have time ...:(


LOL! [duh] im doneeeeee and were suppose to make time to make a script for you that you dont even understand or even care to learn because you dont have time? [lol] [moon] im soooo done.


This.

Also, I thought that in cod2 the islookingat() function is sp only?
Share |
Restricted Access Topic is Locked
Page
Next Page
subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 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

»