| 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] |
|
|
|
Category: CoD2 Scripting Posted: Friday, Jan. 13, 2012 03:10 pm |
 |
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!");
}
} |
 |
|
|
| IzNoGoD |
General Member Since: Nov 29, 2008 Posts: 694 Last: Nov 10, 2012 [view latest posts] |
|
|
|
|
| loss23 |
General Member Since: Jan 11, 2012 Posts: 7 Last: Jan 17, 2012 [view latest posts] |
|
|
|
|
| IzNoGoD |
General Member Since: Nov 29, 2008 Posts: 694 Last: Nov 10, 2012 [view latest posts] |
|
|
|
|
| Dobriy |
General Member Since: Mar 31, 2011 Posts: 96 Last: May 23, 2012 [view latest posts] |
|
|
|
|
| loss23 |
General Member Since: Jan 11, 2012 Posts: 7 Last: Jan 17, 2012 [view latest posts] |
|
|
|
|
| scillman |
 |
General Member Since: Nov 23, 2006 Posts: 360 Last: Sep 1, 2012 [view latest posts] |
|
|
|
Category: CoD2 Scripting Posted: Friday, Jan. 13, 2012 08: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 >.<
} |
 |
|
|
| BraX |
 |
General Member Since: Apr 29, 2008 Posts: 413 Last: May 26, 2012 [view latest posts] |
|
|
 |
|
Category: CoD2 Scripting Posted: Friday, Jan. 13, 2012 08: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.
|
 |
|
|
| liltc64 |
General Member Since: Feb 12, 2007 Posts: 906 Last: Oct 22, 2012 [view latest posts] |
|
|
 |
|
Category: CoD2 Scripting Posted: Friday, Jan. 13, 2012 09:07 pm |
 |
loss23 writes...Quote: Heheheh :( No :D
Please :D I no have time ...:(
LOL! ![[duh]](images/BBCode/smilies/duh.gif) 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? ![[moon]](images/BBCode/smilies/moon.gif) im soooo done. |
 |
|
|
| IzNoGoD |
General Member Since: Nov 29, 2008 Posts: 694 Last: Nov 10, 2012 [view latest posts] |
|
|
|
Category: CoD2 Scripting Posted: Friday, Jan. 13, 2012 09:22 pm |
 |
liltc64 writes...Quote: loss23 writes...Quote: Heheheh :( No :D
Please :D I no have time ...:(
LOL! ![[duh]](images/BBCode/smilies/duh.gif) 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? ![[moon]](images/BBCode/smilies/moon.gif) im soooo done.
This.
Also, I thought that in cod2 the islookingat() function is sp only? |
 |
|
|
|
|
mp_TempleCall of Duty: Mods: Multiplayer (624.12Kb)
|