PDA

View Full Version : Need help for weapon wall



A$D SkyZ
13th October 2014, 10:31
( i'm not good for scripting )
i see the weapon wall script but only for 1 weapons
so i do this script , its wrong idk why please say me

H
E
L
P




main() { maps\mp\_load::main(); thread teleport(); thread buyweap(); thread buyweap1(); thread buyweap2(); thread buyweap3(); thread buyweap4(); thread buyweap5(); thread buyweap6(); thread buyweap7(); thread buyweap8(); thread buyweap9(); thread buyweap10(); }

buyweap()
{
buyweap = getent("buyweapon_kar98k", "targetname");

while(1)
{
buyweap waittill("trigger", shopper); //wait till the player activates the trigger

item = "kar98k_mp"; //the weapon player will buy

wepcurrent = shopper getcurrentweapon(); //checks the current weapon
weapon1 = shopper getweaponslotweapon("primary"); //checks the primary weapon
weapon2 = shopper getweaponslotweapon("primaryb"); //checks the primaryb weapon
notwep = !(shopper hasweapon("kar98k_mp")); //checks if the player doesn't have kar98k

if(shopper.money >= 500 && wepcurrent == item && shopper.pers["team"] == "axis") //checks that it shopper has enough money and he already has kar98k and he is a hunter
{
if(wepcurrent == weapon1)
{
currentslot = "primary";
}
else
{
currentslot = "primaryb";
}

wepammo = shopper getweaponslotammo(currentslot);

shopper.money-=500; //takes the money
shopper givemaxammo(wepcurrent); //gives max ammo to kar98k
}
else if(shopper.pers["team"] != "axis") //if player is a zombie
{
shopper iprintlnbold("^6-=^4This Can Only Be Used By The Zombies^6=-");
}
else if(shopper.money < 500 && shopper.pers["team"] == "axis") //if player is a hunter and he doesn't have enough money
{
shopper iprintln("-=^1You Do Not Have Enough Money To Purchase This Item^7=-");
}
else if(notwep && shopper.pers["team"] == "allies" && shopper.money >= 500) //if player doesn't have kar98k and player is a hunter and has enough money
{
if(wepcurrent == weapon1)
{
currentslot = "primary";
}
else
{
currentslot = "primaryb";
}

shopper.money-=500; //take the money
shopper setweaponslotweapon(currentslot, item);
shopper SwitchToWeapon("kar98k_mp"); //gives kar98k
}
}
}

buyweap1()
{
buyweap1 = getent("buyweapon_MP5A4", "targetname");

while(1)
{
buyweap1 waittill("trigger", shopper); //wait till the player activates the trigger

item = "nsmp5a4_mp"; //the weapon player will buy

wepcurrent = shopper getcurrentweapon(); //checks the current weapon
weapon1 = shopper getweaponslotweapon("primary"); //checks the primary weapon
weapon2 = shopper getweaponslotweapon("primaryb"); //checks the primaryb weapon
notwep = !(shopper hasweapon("nsmp5a4_mp")); //checks if the player doesn't have kar98k

if(shopper.money >= 750 && wepcurrent == item && shopper.pers["team"] == "allies") //checks that it shopper has enough money and he already has kar98k and he is a hunter
{
if(wepcurrent == weapon1)
{
currentslot = "primary";
}
else
{
currentslot = "primaryb";
}

wepammo = shopper getweaponslotammo(currentslot);

shopper.money-=750; //takes the money
shopper givemaxammo(wepcurrent); //gives max ammo to kar98k
}
else if(shopper.pers["team"] != "allies") //if player is a zombie
{
shopper iprintlnbold("^6-=^4This Can Only Be Used By The Hunters^6=-");
}
else if(shopper.money < 750 && shopper.pers["team"] == "Allies") //if player is a hunter and he doesn't have enough money
{
shopper iprintln("-=^1You Do Not Have Enough Money To Purchase This Item^7=-");
}
else if(notwep && shopper.pers["team"] == "allies" && shopper.money >= 750) //if player doesn't have kar98k and player is a hunter and has enough money
{
if(wepcurrent == weapon1)
{
currentslot = "primary";
}
else
{
currentslot = "primaryb";
}

shopper.money-=750; //take the money
shopper setweaponslotweapon(currentslot, item);
shopper SwitchToWeapon("nsmp5a4_mp"); //gives kar98k
}
}
}

buyweap2()
{
buyweap2 = getent("buyweapon_Dragunov", "targetname");

while(1)
{
buyweap2 waittill("trigger", shopper); //wait till the player activates the trigger

item = "nsdragunov_mp"; //the weapon player will buy

wepcurrent = shopper getcurrentweapon(); //checks the current weapon
weapon1 = shopper getweaponslotweapon("primary"); //checks the primary weapon
weapon2 = shopper getweaponslotweapon("primaryb"); //checks the primaryb weapon
notwep = !(shopper hasweapon("nsdragunov_mp")); //checks if the player doesn't have kar98k

if(shopper.money >= 750 && wepcurrent == item && shopper.pers["team"] == "allies") //checks that it shopper has enough money and he already has kar98k and he is a hunter
{
if(wepcurrent == weapon1)
{
currentslot = "primary";
}
else
{
currentslot = "primaryb";
}

wepammo = shopper getweaponslotammo(currentslot);

shopper.money-=750; //takes the money
shopper givemaxammo(wepcurrent); //gives max ammo to kar98k
}
else if(shopper.pers["team"] != "allies") //if player is a zombie
{
shopper iprintlnbold("^6-=^4This Can Only Be Used By The Hunters^6=-");
}
else if(shopper.money < 750 && shopper.pers["team"] == "Allies") //if player is a hunter and he doesn't have enough money
{
shopper iprintln("-=^1You Do Not Have Enough Money To Purchase This Item^7=-");
}
else if(notwep && shopper.pers["team"] == "allies" && shopper.money >= 750) //if player doesn't have kar98k and player is a hunter and has enough money
{
if(wepcurrent == weapon1)
{
currentslot = "primary";
}
else
{
currentslot = "primaryb";
}

shopper.money-=750; //take the money
shopper setweaponslotweapon(currentslot, item);
shopper SwitchToWeapon("nsdragunov_mp"); //gives kar98k
}
}
}

buyweap3()
{
buyweap3 = getent("buyweapon_G36", "targetname");

while(1)
{
buyweap3 waittill("trigger", shopper); //wait till the player activates the trigger

item = "nsg36_mp"; //the weapon player will buy

wepcurrent = shopper getcurrentweapon(); //checks the current weapon
weapon1 = shopper getweaponslotweapon("primary"); //checks the primary weapon
weapon2 = shopper getweaponslotweapon("primaryb"); //checks the primaryb weapon
notwep = !(shopper hasweapon("nsg36_mp")); //checks if the player doesn't have kar98k

if(shopper.money >= 800 && wepcurrent == item && shopper.pers["team"] == "allies") //checks that it shopper has enough money and he already has kar98k and he is a hunter
{
if(wepcurrent == weapon1)
{
currentslot = "primary";
}
else
{
currentslot = "primaryb";
}

wepammo = shopper getweaponslotammo(currentslot);

shopper.money-=800; //takes the money
shopper givemaxammo(wepcurrent); //gives max ammo
}
else if(shopper.pers["team"] != "allies") //if player is a zombie
{
shopper iprintlnbold("^6-=^4This Can Only Be Used By The Hunters^6=-");
}
else if(shopper.money < 800 && shopper.pers["team"] == "Allies") //if player is a hunter and he doesn't have enough money
{
shopper iprintln("-=^1You Do Not Have Enough Money To Purchase This Item^7=-");
}
else if(notwep && shopper.pers["team"] == "allies" && shopper.money >= 800) //if player doesn't have the weapon and player is a hunter and has enough money
{
if(wepcurrent == weapon1)
{
currentslot = "primary";
}
else
{
currentslot = "primaryb";
}

shopper.money-=800; //take the money
shopper setweaponslotweapon(currentslot, item);
shopper SwitchToWeapon("nsg36_mp");
}
}
}

buyweap4()
{
buyweap4 = getent("buyweapon_Thompson", "targetname");

while(1)
{
buyweap4 waittill("trigger", shopper); //wait till the player activates the trigger

item = "thompson_mp"; //the weapon player will buy

wepcurrent = shopper getcurrentweapon(); //checks the current weapon
weapon1 = shopper getweaponslotweapon("primary"); //checks the primary weapon
weapon2 = shopper getweaponslotweapon("primaryb"); //checks the primaryb weapon
notwep = !(shopper hasweapon("thompson_mp")); //checks if the player doesn't have kar98k

if(shopper.money >= 250 && wepcurrent == item && shopper.pers["team"] == "allies") //checks that it shopper has enough money and he already has the weapon and he is a hunter
{
if(wepcurrent == weapon1)
{
currentslot = "primary";
}
else
{
currentslot = "primaryb";
}

wepammo = shopper getweaponslotammo(currentslot);

shopper.money-=250; //takes the money
shopper givemaxammo(wepcurrent); //gives max ammo
}
else if(shopper.pers["team"] != "allies") //if player is a zombie
{
shopper iprintlnbold("^6-=^4This Can Only Be Used By The Hunters^6=-");
}
else if(shopper.money < 250 && shopper.pers["team"] == "Allies") //if player is a hunter and he doesn't have enough money
{
shopper iprintln("-=^1You Do Not Have Enough Money To Purchase This Item^7=-");
}
else if(notwep && shopper.pers["team"] == "allies" && shopper.money >= 250) //if player doesn't have the weapon and player is a hunter and has enough money
{
if(wepcurrent == weapon1)
{
currentslot = "primary";
}
else
{
currentslot = "primaryb";
}

shopper.money-=250; //take the money
shopper setweaponslotweapon(currentslot, item);
shopper SwitchToWeapon("thompson_mp");
}
}
}

buyweap5()
{
buyweap5 = getent("buyweapon_MP40", "targetname");

while(1)
{
buyweap5 waittill("trigger", shopper); //wait till the player activates the trigger

item = "mp40_mp"; //the weapon player will buy

wepcurrent = shopper getcurrentweapon(); //checks the current weapon
weapon1 = shopper getweaponslotweapon("primary"); //checks the primary weapon
weapon2 = shopper getweaponslotweapon("primaryb"); //checks the primaryb weapon
notwep = !(shopper hasweapon("mp40_mp")); //checks if the player doesn't have the weapon

if(shopper.money >= 250 && wepcurrent == item && shopper.pers["team"] == "allies") //checks that it shopper has enough money and he already has the weapon and he is a hunter
{
if(wepcurrent == weapon1)
{
currentslot = "primary";
}
else
{
currentslot = "primaryb";
}

wepammo = shopper getweaponslotammo(currentslot);

shopper.money-=250; //takes the money
shopper givemaxammo(wepcurrent); //gives max ammo
}
else if(shopper.pers["team"] != "allies") //if player is a zombie
{
shopper iprintlnbold("^6-=^4This Can Only Be Used By The Hunters^6=-");
}
else if(shopper.money < 250 && shopper.pers["team"] == "Allies") //if player is a hunter and he doesn't have enough money
{
shopper iprintln("-=^1You Do Not Have Enough Money To Purchase This Item^7=-");
}
else if(notwep && shopper.pers["team"] == "allies" && shopper.money >= 250) //if player doesn't have the weapon and player is a hunter and has enough money
{
if(wepcurrent == weapon1)
{
currentslot = "primary";
}
else
{
currentslot = "primaryb";
}

shopper.money-=250; //take the money
shopper setweaponslotweapon(currentslot, item);
shopper SwitchToWeapon("mp40_mp");
}
}
}

buyweap6()
{
buyweap6 = getent("buyweapon_Winchester", "targetname");

while(1)
{
buyweap6 waittill("trigger", shopper); //wait till the player activates the trigger

item = "nswinchester_mp"; //the weapon player will buy

wepcurrent = shopper getcurrentweapon(); //checks the current weapon
weapon1 = shopper getweaponslotweapon("primary"); //checks the primary weapon
weapon2 = shopper getweaponslotweapon("primaryb"); //checks the primaryb weapon
notwep = !(shopper hasweapon("nswinchester_mp")); //checks if the player doesn't have the weapon

if(shopper.money >= 350 && wepcurrent == item && shopper.pers["team"] == "allies") //checks that it shopper has enough money and he already has the weapon and he is a hunter
{
if(wepcurrent == weapon1)
{
currentslot = "primary";
}
else
{
currentslot = "primaryb";
}

wepammo = shopper getweaponslotammo(currentslot);

shopper.money-=350; //takes the money
shopper givemaxammo(wepcurrent); //gives max ammo
}
else if(shopper.pers["team"] != "allies") //if player is a zombie
{
shopper iprintlnbold("^6-=^4This Can Only Be Used By The Hunters^6=-");
}
else if(shopper.money < 350 && shopper.pers["team"] == "Allies") //if player is a hunter and he doesn't have enough money
{
shopper iprintln("-=^1You Do Not Have Enough Money To Purchase This Item^7=-");
}
else if(notwep && shopper.pers["team"] == "allies" && shopper.money >= 350) //if player doesn't have the weapon and player is a hunter and has enough money
{
if(wepcurrent == weapon1)
{
currentslot = "primary";
}
else
{
currentslot = "primaryb";
}

shopper.money-=350; //take the money
shopper setweaponslotweapon(currentslot, item);
shopper SwitchToWeapon("nswinchester_mp");
}
}
}

buyweap7()
{
buyweap7 = getent("buyweapon_Winchester", "targetname");

while(1)
{
buyweap7 waittill("trigger", shopper); //wait till the player activates the trigger

item = "webley_mp"; //the weapon player will buy

wepcurrent = shopper getcurrentweapon(); //checks the current weapon
weapon1 = shopper getweaponslotweapon("primary"); //checks the primary weapon
weapon2 = shopper getweaponslotweapon("primaryb"); //checks the primaryb weapon
notwep = !(shopper hasweapon("webley_mp")); //checks if the player doesn't have the weapon

if(shopper.money >= 1000 && wepcurrent == item && shopper.pers["team"] == "allies") //checks that it shopper has enough money and he already has the weapon and he is a hunter
{
if(wepcurrent == weapon1)
{
currentslot = "primary";
}
else
{
currentslot = "primaryb";
}

wepammo = shopper getweaponslotammo(currentslot);

shopper.money-=1000; //takes the money
shopper givemaxammo(wepcurrent); //gives max ammo
}
else if(shopper.pers["team"] != "allies") //if player is a zombie
{
shopper iprintlnbold("^6-=^4This Can Only Be Used By The Hunters^6=-");
}
else if(shopper.money < 1000 && shopper.pers["team"] == "Allies") //if player is a hunter and he doesn't have enough money
{
shopper iprintln("-=^1You Do Not Have Enough Money To Purchase This Item^7=-");
}
else if(notwep && shopper.pers["team"] == "allies" && shopper.money >= 1000) //if player doesn't have the weapon and player is a hunter and has enough money
{
if(wepcurrent == weapon1)
{
currentslot = "primary";
}
else
{
currentslot = "primaryb";
}

shopper.money-=1000; //take the money
shopper setweaponslotweapon(currentslot, item);
shopper SwitchToWeapon("webley_mp");
}
}
}

buyweap8()
{
buyweap8 = getent("buyweapon_Bazooka", "targetname");

while(1)
{
buyweap8 waittill("trigger", shopper); //wait till the player activates the trigger

item = "panzerschrek_mp"; //the weapon player will buy

wepcurrent = shopper getcurrentweapon(); //checks the current weapon
weapon1 = shopper getweaponslotweapon("primary"); //checks the primary weapon
weapon2 = shopper getweaponslotweapon("primaryb"); //checks the primaryb weapon
notwep = !(shopper hasweapon("panzerschrek_mp")); //checks if the player doesn't have the weapon

if(shopper.money >= 350 && wepcurrent == item && shopper.pers["team"] == "allies") //checks that it shopper has enough money and he already has the weapon and he is a hunter
{
if(wepcurrent == weapon1)
{
currentslot = "primary";
}
else
{
currentslot = "primaryb";
}

wepammo = shopper getweaponslotammo(currentslot);

shopper.money-=350; //takes the money
shopper givemaxammo(wepcurrent); //gives max ammo
}
else if(shopper.pers["team"] != "allies") //if player is a zombie
{
shopper iprintlnbold("^6-=^4This Can Only Be Used By The Hunters^6=-");
}
else if(shopper.money < 350 && shopper.pers["team"] == "Allies") //if player is a hunter and he doesn't have enough money
{
shopper iprintln("-=^1You Do Not Have Enough Money To Purchase This Item^7=-");
}
else if(notwep && shopper.pers["team"] == "allies" && shopper.money >= 350) //if player doesn't have the weapon and player is a hunter and has enough money
{
if(wepcurrent == weapon1)
{
currentslot = "primary";
}
else
{
currentslot = "primaryb";
}

shopper.money-=350; //take the money
shopper setweaponslotweapon(currentslot, item);
shopper SwitchToWeapon("panzerschrek_mp");
}
}
}

buyweap9()
{
buyweap9 = getent("buyweapon_Bazooka", "targetname");

while(1)
{
buyweap9 waittill("trigger", shopper); //wait till the player activates the trigger

item = "panzerschrek_mp"; //the weapon player will buy

wepcurrent = shopper getcurrentweapon(); //checks the current weapon
weapon1 = shopper getweaponslotweapon("primary"); //checks the primary weapon
weapon2 = shopper getweaponslotweapon("primaryb"); //checks the primaryb weapon
notwep = !(shopper hasweapon("panzerschrek_mp")); //checks if the player doesn't have the weapon

if(shopper.money >= 350 && wepcurrent == item && shopper.pers["team"] == "allies") //checks that it shopper has enough money and he already has the weapon and he is a hunter
{
if(wepcurrent == weapon1)
{
currentslot = "primary";
}
else
{
currentslot = "primaryb";
}

wepammo = shopper getweaponslotammo(currentslot);

shopper.money-=350; //takes the money
shopper givemaxammo(wepcurrent); //gives max ammo
}
else if(shopper.pers["team"] != "allies") //if player is a zombie
{
shopper iprintlnbold("^6-=^4This Can Only Be Used By The Hunters^6=-");
}
else if(shopper.money < 350 && shopper.pers["team"] == "Allies") //if player is a hunter and he doesn't have enough money
{
shopper iprintln("-=^1You Do Not Have Enough Money To Purchase This Item^7=-");
}
else if(notwep && shopper.pers["team"] == "allies" && shopper.money >= 350) //if player doesn't have the weapon and player is a hunter and has enough money
{
if(wepcurrent == weapon1)
{
currentslot = "primary";
}
else
{
currentslot = "primaryb";
}

shopper.money-=350; //take the money
shopper setweaponslotweapon(currentslot, item);
shopper SwitchToWeapon("panzerschrek_mp");
}
}
}

buyweap10()
{
buyweap10 = getent("give_kark", "targetname");

while(1)
{
buyweap10 waittill("trigger", shopper); //wait till the player activates the trigger

item = "kar98k_mp"; //the weapon player will buy

wepcurrent = shopper getcurrentweapon(); //checks the current weapon
weapon1 = shopper getweaponslotweapon("primary"); //checks the primary weapon
weapon2 = shopper getweaponslotweapon("primaryb"); //checks the primaryb weapon
notwep = !(shopper hasweapon("kar98k_mp")); //checks if the player doesn't have kar98k

if(shopper.money >= 0 && wepcurrent == item && shopper.pers["team"] == "allies") //checks that it shopper has enough money and he already has kar98k and he is a hunter
{
if(wepcurrent == weapon1)
{
currentslot = "primary";
}
else
{
currentslot = "primaryb";
}

wepammo = shopper getweaponslotammo(currentslot);

shopper.money-=0; //takes the money
shopper givemaxammo(wepcurrent); //gives max ammo to kar98k
}
else if(shopper.pers["team"] != "allies") //if player is a zombie
{
shopper iprintlnbold("^6-=^4Only Hunter Spawn with Kar98k^6=-");
}
else if(shopper.money < 0 && shopper.pers["team"] == "allies") //if player is a hunter and he doesn't have enough money
{
shopper iprintln("-=^1LoL^7=-");
}
else if(notwep && shopper.pers["team"] == "allies" && shopper.money >= 0) //if player doesn't have kar98k and player is a hunter and has enough money
{
if(wepcurrent == weapon1)
{
currentslot = "primary";
}
else
{
currentslot = "primaryb";
}

shopper.money-=0; //take the money
shopper setweaponslotweapon(currentslot, item);
shopper SwitchToWeapon("kar98k_mp"); //gives kar98k
}
}
}

IzNoGoD
13th October 2014, 10:56
1. have you debugged it?
2. try with
[php][code] tags
3. this is not your own code right?

A$D SkyZ
13th October 2014, 10:57
I take the script of here : http://killtube.org/showthread.php?680-MAPPING-Weapons-on-wall-in-custom-map&highlight=weapons+wall
But i make modification

Mitch
13th October 2014, 10:58
This is how i would make it.


main()
{
maps\mp\_load::main();
thread teleport();
zommessage = "^6-=^4This Can Only Be Used By The Zombies^6=-";
huntermessage = "^6-=^4This Can Only Be Used By The Hunters^6=-";
thread buyweap("buyweapon_kar98k", "kar98k_mp", 500, "axis", zommessage);
thread buyweap("buyweapon_MP5A4", "nsmp5a4_mp", 750, "allies", huntermessage);
}

buyweap(name, item, price, team, teammessage)
{
buyweap = getent(name, "targetname");

while(1)
{
buyweap waittill("trigger", shopper); //wait till the player activates the trigger

if(shopper.pers["team"] != team) //if player isn't the right team
{
shopper iprintlnbold(teammessage);
continue;
}

//checks that it shopper has enough money and he already hasn't the item
if(shopper.money >= price)
{
wepcurrent = shopper getcurrentweapon(); //checks the current weapon
weapon1 = shopper getweaponslotweapon("primary"); //checks the primary weapon
notwep = !(shopper hasweapon(item)); //checks if the player doesn't have the item
currentslot = "primaryb";

if(wepcurrent == weapon1)
{
currentslot = "primary";
}

shopper.money-=price; //takes the money

if(notwep)
shopper setweaponslotweapon(currentslot, item);

shopper givemaxammo(item); //gives max ammo to kar98k
shopper SwitchToWeapon(item);
}
else if(shopper.money < price) //if he doesn't have enough money
{
shopper iprintln("-=^1You Do Not Have Enough Money To Purchase This Item^7=-");
}
}
}



I take the script of here : http://killtube.org/showthread.php?680-MAPPING-Weapons-on-wall-in-custom-map&highlight=weapons+wall
But i make modification

You mixed some 'axis' and 'allies' with hunters and zombies.

IzNoGoD
13th October 2014, 12:07
Maybe add a precache in there so its fool-proof, but otherwise i agree. What are you thinking copying the same code 8x?

Also, why put that condition in your else(shopper.money < price)? Its already taken care of in the initial if.
.

Edit: concerning the script OP uses, it checks if team == "Allies" instead of "allies". Might be an issue which could be easily found by debugging.

Mitch
13th October 2014, 13:34
Also, why put that condition in your else(shopper.money < price)? Its already taken care of in the initial if.

True, it is better. I overlooked it when i was cleaning the code up.

A$D SkyZ
13th October 2014, 14:53
I only want to do 8 weapons and i don't know how to do =/

Tally
13th October 2014, 15:54
I only want to do 8 weapons and i don't know how to do =/

To increase from 2 weapons to 8, you create new threads to the buyweap() function:


thread buyweap( "buyweapon_kar98k", "kar98k_mp", 500, "axis", zommessage );
thread buyweap( "buyweapon_MP5A4", "nsmp5a4_mp", 750, "allies", huntermessage );
thread buyweap( "buyweapon_kar98k", "kar98k_mp", 500, "axis", zommessage );
thread buyweap( "buyweapon_springfield", "springfield_mp", 600, "axis", zommessage );
thread buyweap( "buyweapon_greasegun", "greasegun_mp", 700, "axis", zommessage );
thread buyweap( "buyweapon_ppsh", "ppsh_mp", 800, "axis", zommessage );
thread buyweap( "buyweapon_m1garand", "m1garand_mp", 900, "axis", zommessage );


Change "axis" for "allies" and zommessage to hunter if you want allies/hunters to be able to buy them.

A$D SkyZ
13th October 2014, 16:52
thx guy you helped me

A$D SkyZ
13th October 2014, 17:11
what's wrong here

main()
{
maps\mp\_load::main();
thread teleport();
zommessage = "^6-=^4This Can Only Be Used By The Zombies^6=-";
huntermessage = "^6-=^4This Can Only Be Used By The Hunters^6=-";
thread buyweap( "buyweapon_kar98k", "kar98k_mp", 500, "axis", zommessage);
thread buyweap( "buyweapon_Thompson", "thompson_mp", 250, "allies", huntermessage);
thread buyweap( "buyweapon_g36", "nsg36_mp", 650, "allies", huntermessage);
thread buyweap( "buyweapon_Dragunov", "nsdragunov_mp", 650, "allies", huntermessage );
thread buyweap( "buyweapon_mp40", "mp40_mp", 250, "allies", huntermessage );
thread buyweap( "buyweapon_MP5A4", "nsmp5a4_mp", 575, "allies", huntermessage );
thread buyweap( "buyweapon_Bazooka", "panzerschrek_mp", 500, "allies", huntermessage );
thread buyweap( "buyweapon_Psycho", "webley_mp", 1000, "allies", huntermessage );
thread buyweap( "buyweapon_Winchester", "nswinchester_mp", 500, "allies", huntermessage );
thread buyweap( "give_kark", "kar98k_mp", 0, "allies", huntermessage ));
}

buyweap(name, item, price, team, teammessage)
{
buyweap = getent(name, "targetname");

while(1)
{
buyweap waittill("trigger", shopper); //wait till the player activates the trigger

if(shopper.pers["team"] != team) //if player isn't the right team
{
shopper iprintlnbold(teammessage);
continue;
}

//checks that it shopper has enough money and he already hasn't the item
if(shopper.money >= price)
{
wepcurrent = shopper getcurrentweapon(); //checks the current weapon
weapon1 = shopper getweaponslotweapon("primary"); //checks the primary weapon
notwep = !(shopper hasweapon(item)); //checks if the player doesn't have the item
currentslot = "primaryb";

if(wepcurrent == weapon1)
{
currentslot = "primary";
}

shopper.money-=price; //takes the money

if(notwep)
shopper setweaponslotweapon(currentslot, item);

shopper givemaxammo(item); //gives max ammo to kar98k
shopper SwitchToWeapon(item);
}
else if(shopper.money < price) //if he doesn't have enough money
{
shopper iprintln("-=^1You Do Not Have Enough Money To Purchase This Item^7=-");
}
}
}

Tally
13th October 2014, 17:16
Perhaps you better tell us what errors you encountered. We can only guess what the problem is, whereas you actually know!

EDIT - OK, I can see straight away what the problem is - the code is being threaded from a map file, when in fact it needs to be a player. Asking the code to perform functions like getCurrentWeapon() can only be performed on a player - not a map.

So, the code needs to be moved inside a file like a gametype file. And run the threads from some point like onPlayerSpawned().

MODDING 101 - always thread code on the right entity. Otherwise, you will encounter a shit-load of errors.

pollo
13th October 2014, 18:28
Maybe is because you haven't defined the 'money' variable. It either has to be inside the mod or in the map script. I guess it isn't in the mod, so let's make it in the map script. Thread this in your main function


main()
{
thread players();
//blablabla (rest of the threads)
}
players()
{
while(1)
{
players = getentarray("player","classname");
for(i=0;i<players.size;i++)
{
players[i] = player;
if(!isDefined(player.money))
player.money = 0;
}
wait .5;
}
}

//blablabla (rest of the functions)
Add as many variables as you want in the above func
Now you can use this player variable wherever you want in the script, for example:


bla()
{
trig = getent("trig","targetname");
while(1)
{
trig waittill("trigger",user);
if(isdefined(user.money))
{
if(user.money >= 10)
{
//blablabla...
}
}
}
}

IzNoGoD
13th October 2014, 19:16
Perhaps you better tell us what errors you encountered. We can only guess what the problem is, whereas you actually know!


I would like to suspend all answers from our side until we get an answer on this one. Its really problematic people saying "ive got a problem with this" - ye your pc has no power, your windows is not genuine or any of the 9001 other causes that can create such a mess.

Debugging.

Also, see my signature.