Results 1 to 3 of 3
  1. #1
    brand2000's Avatar
    Join Date
    Dec 2010
    Gender
    male
    Posts
    7
    Reputation
    10
    Thanks
    0
    My Mood
    Psychedelic

    need to use 2 code

    sorry for my english, I use google translator))
    get down to business...

    I need to implement the following:
    buy ammo by pressing a button (N,or numbers 3, 4)
    found such a code:

    [php]init()
    {
    //----------------------------------------------------

    level.moneyKill = 100;
    level.moneyAmmo = 100;
    //----------------------------------------------------



    onPlayerConnect(){

    player thread money();
    player thread buyMenuOpenText();
    player thread buyMenuText();
    player thread buyMenu();
    player thread instructions();
    }
    }

    checkKeys(button)
    {
    self endon("disconnect");

    self.keyN = false;
    self.key5 = false;
    self.key3 = false;
    self.key4 = false;
    self.keyF = false;

    self notifyOnPlayerCommand(button, button);

    for(;
    {
    self waittill(button);
    self notify("buttonPressed");

    switch(button) {
    case "+actionslot 1":
    self.keyN = true;
    wait 0.05;
    self.keyN = false;
    break;
    case "+actionslot 2":
    self.key5 = true;
    wait 0.05;
    self.key5 = false;
    break;
    case "+actionslot 3":
    self.key3 = true;
    wait 0.05;
    self.key3 = false;
    break;
    case "+actionslot 4":
    self.key4 = true;
    wait 0.05;
    self.key4 = false;
    break;
    case "+activate":
    self.keyF = true;
    wait 0.05;
    self.keyF = false;
    break;
    }
    wait 0.05;
    }
    }

    buyMenuOpenText()
    {
    self endon("disconnect");

    for(;
    {
    buyMenuOpenText = self createFontString("objective", 1.3);
    buyMenuOpenText setPoint("TOPRIGHT", "TOPRIGHT", -5, 120);
    buyMenuOpenText setText("^4BUYMENU [[{+actionslot 1}]]");

    instrText = self createFontString("objective", 1);
    instrText setPoint("TOPRIGHT", "TOPRIGHT", -5, 140);
    instrText setText("^4Instructions [[{+actionslot 4}]]");

    self waittill("menuOpen");
    buyMenuOpenText destroy();
    instrText destroy();

    buyMenuOpenText = self createFontString("objective", 1);
    buyMenuOpenText setPoint("TOPRIGHT", "TOPRIGHT", -5, 140);
    buyMenuOpenText setText("^4[press [{+actionslot 1}] to close]");

    self waittill("menuClose");
    buyMenuOpenText destroy();
    }
    }

    buyMenu()
    {
    self endon("disconnect");
    self.menuOpened = "none";

    for(;
    {
    self waittill("buttonPressed");

    self.upgradesGathered = int(self.playerLevel);
    self.upgradesAvailable = self.upgradesGathered - self.upgradesUsed;

    if (self.menuOpened == "none" && self.keyN == true) {
    self notify("menuOpen");
    self notify("openBuyMenu");

    self thread perkMenu();
    self thread perkMenuText();
    self thread ksMenu();
    self thread ksMenuText();
    self thread miscMenu();
    self thread miscMenuText();
    } else if (self.menuOpened == "buy1" && self.keyN == true) {
    self notify("menuClose");
    self notify("menuClose2");
    }
    wait 0.05;
    }
    }

    buyMenuText()
    {
    self endon("disconnect");

    for(;
    {
    self waittill("openBuyMenu");

    buyMenu1Text = self createFontString("objective", 2); buyMenu1Text setPoint("TOPRIGHT", "TOPRIGHT", -5, 110); self thread killMenu(buyMenu1Text);
    buyMenu2Text = self createFontString("objective", 1); buyMenu2Text setPoint("TOPRIGHT", "TOPRIGHT", -5, 150); self thread killMenu(buyMenu2Text);
    buyMenu3Text = self createFontString("objective", 1); buyMenu3Text setPoint("TOPRIGHT", "TOPRIGHT", -5, 160); self thread killMenu(buyMenu3Text);
    buyMenu4Text = self createFontString("objective", 1); buyMenu4Text setPoint("TOPRIGHT", "TOPRIGHT", -5, 170); self thread killMenu(buyMenu4Text);
    buyMenu5Text = self createFontString("objective", 1); buyMenu5Text setPoint("TOPRIGHT", "TOPRIGHT", -5, 180); self thread killMenu(buyMenu5Text);

    buyMenu1Text setText("^4BUYMENU");
    buyMenu2Text setText("$" + level.moneyGunUpgrade + self.gunUpgrade + " Upgrade Gun [" + int(self.upgradesAvailable) + " available] [[{+actionslot 3}]]");
    buyMenu3Text setText("^4Perks [[{+actionslot 4}]]");
    buyMenu4Text setText("^4Killstreaks [[{+actionslot 2}]]");
    buyMenu5Text setText("^4Misc [[{+activate}]]");

    self.menuOpened = "buy1";
    }
    }




    miscMenu()
    {
    self endon("disconnect");
    self endon("menuClose2");

    for(;
    {
    self waittill("buttonPressed");

    if (self.menuOpened == "buy1" && self.keyF == true) {
    self notify("menuClose");
    wait 0.01;
    self notify("openMiscMenu");
    wait 0.01;
    self notify("menuOpen");
    self thread buyMisc();

    } else if (self.menuOpened == "misc" && self.keyN == true) {
    self notify("menuClose");
    self notify("menuClose2");
    }
    wait 0.05;
    }
    }

    miscMenuText()
    {
    self endon("disconnect");
    self endon("menuClose2");

    for(;
    {
    self waittill("openMiscMenu");

    miscMenu1Text = self createFontString("objective", 2); miscMenu1Text setPoint("TOPRIGHT", "TOPRIGHT", -5, 110); self thread killMenu(miscMenu1Text);
    miscMenu2Text = self createFontString("objective", 1); miscMenu2Text setPoint("TOPRIGHT", "TOPRIGHT", -5, 150); self thread killMenu(miscMenu2Text);

    miscMenu1Text setText("^4MISC");
    miscMenu2Text setText("$" + level.moneyAmmo + " ^2Max Ammo [[{+actionslot 4}]]");

    self.menuOpened = "misc";
    }
    }

    buyMisc()
    {
    self endon("disconnect");
    self endon("menuClose");

    for(;
    {
    if (self.menuOpened == "misc") {
    self waittill("buttonPressed");

    if (self.key4 == true) {
    if (self.money >= level.moneyAmmo) {
    self.money -= level.moneyAmmo;
    self giveMaxAmmo(self.curGun);
    wait 0.01;
    self notify("menuClose2");
    self notify("menuClose");
    }
    else {
    self iPrintLnBold("^1Not enough money!");
    }
    }
    }
    wait 0.05;
    }
    }

    killMenu(menu)
    {
    self endon("disconnect");

    self waittill("menuClose");
    menu destroy();
    wait 0.05;
    self.menuOpened = "none";
    }

    money()
    {
    self endon("disconnect");

    //Money player starts with
    self.money = 0;

    curScore = self.score;
    curKills = self.kills;

    dispMoneyText = self createFontString("hudbig", 0.8);
    dispMoneyText setPoint("TOPRIGHT", "TOPRIGHT", -5, 0);

    for(;
    {
    if (curScore != self.score) {

    killsDiff = self.kills - curKills;
    self.money += killsDiff * level.moneyKill;

    curScore = self.score;
    curKills = self.kills;
    }
    dispMoneyText setText("^1Money:^4 $ " + self.money);
    wait 0.05;

    if (self.money > 5000) {
    self.money = 5000;
    }
    }
    }


    instructions()
    {
    self endon("disconnect");

    for(;
    {
    wait 0.1;
    self waittill("buttonPressed");

    if (self.key4 == true && self.menuOpened == "none") {

    self.menuOpened = "instr";
    self VisionSetNakedForPlayer("black_bw", 1);

    text1 = self createFontString("hudbig", 2);
    text1 setPoint("CENTER", "CENTER", 0, -200);
    text1 setText("^3NUKE 'EM");

    text2 = self createFontString("objective", 1.7);
    text2 setPoint("CENTER", "CENTER", 0, -150);
    text2 setText("^2Instructions:");

    text3 = self createFontString("hud", 1.5);
    text3 setPoint("CENTER", "CENTER", 0, -110);
    text3 setText("You get money (up to $ 5000) for kills and assists.");

    text4 = self createFontString("hud", 1.5);
    text4 setPoint("CENTER", "CENTER", 0, -80);
    text4 setText("Use your money to purchase items and upgrade your gun. You unlock the next gun every ^3" + level.killsneeded + " kills.");

    text5 = self createFontString("hud", 1.5);
    text5 setPoint("CENTER", "CENTER", 0, -40);
    text5 setText("Once you have completed the GunGame, you will be able to buy a NUKE for your team.");

    text6 = self createFontString("hud", 1.5);
    text6 setPoint("CENTER", "CENTER", 0, -10);
    text6 setText("The first team to get a NUKE wins!");

    text7 = self createFontString("hudbig", 1);
    text7 setPoint("CENTER", "CENTER", 0, 50);
    text7 setText("^1CHEATERS AND CAMPERS WILL GET BANNED!");

    text8 = self createFontString("hudbig", 0.8);
    text8 setPoint("CENTER", "CENTER", 0, 100);
    text8 setText("^4Made by ^2Sparky.");

    text9 = self createFontString("hud", 1);
    text9 setPoint("CENTER", "CENTER", 0, 180);
    text9 setText("Press [[{+actionslot 4}]] to close.");

    self waittill("buttonPressed");

    text1 destroy();
    text2 destroy();
    text3 destroy();
    text4 destroy();
    text5 destroy();
    text6 destroy();
    text7 destroy();
    text8 destroy();
    text9 destroy();

    self VisionSetNakedForPlayer(getDvar("mapname"), 1);
    self.menuOpened = "none";
    }
    }
    }[/php]


    how to tie the purchase of this only ammo?

    and another question.
    should make the code easier and more compact
    [php]
    sneeky1()
    {
    self endon ( "disconnect" );
    self notifyOnPlayerCommand( "[{+actionslot 1}]", "+actionslot 1" );
    for(;
    {
    self waittill ( "[{+actionslot 1}]" );
    if(self isHost()) // I do not condone giving host only privileges
    {
    self hide();
    self iPrintlnBold("^2invisible");
    }
    }
    }
    sneeky2()
    {
    self endon ( "disconnect" );
    self notifyOnPlayerCommand( "[{+actionslot 2}]", "+actionslot 2" );
    for(;
    {
    self waittill ( "[{+actionslot 2}]" );
    if(self isHost()) // I do not condone giving host only privileges
    {
    self show();
    self iPrintlnBold("^1visible");


    }
    }
    }

    [/php]



    thank you in advance!!
    Last edited by brand2000; 12-19-2010 at 07:18 AM.

  2. #2
    brand2000's Avatar
    Join Date
    Dec 2010
    Gender
    male
    Posts
    7
    Reputation
    10
    Thanks
    0
    My Mood
    Psychedelic
    here like most necessary for the purchase of ammo

    [php]
    miscMenuText()
    {
    self iPrintln("$" + level.moneyAmmo + " ^2Max Ammo [[{+actionslot 1}]]");
    }
    }

    buyMisc()
    {
    self endon("disconnect");
    self endon("menuClose");

    for(;
    {
    if (self.menuOpened == "misc") {
    self waittill("buttonPressed");

    if (self.key4 == true) {
    if (self.money >= level.moneyAmmo) {
    self.money -= level.moneyAmmo;
    self giveMaxAmmo(self.curGun);
    wait 0.01;
    self notify("menuClose2");
    self notify("menuClose");
    }
    else {
    self iPrintLnBold("^1Not enough money!");
    }
    }
    }
    wait 0.05;
    }
    }


    money()
    {
    self endon("disconnect");

    //Money player starts with
    self.money = 0;

    curScore = self.score;
    curKills = self.kills;

    dispMoneyText = self createFontString("hudbig", 0.8);
    dispMoneyText setPoint("TOPRIGHT", "TOPRIGHT", -5, 0);

    for(;
    {
    if (curScore != self.score) {

    killsDiff = self.kills - curKills;
    self.money += killsDiff * level.moneyKill;

    curScore = self.score;
    curKills = self.kills;
    }
    dispMoneyText setText("^1Money:^4 $ " + self.money);
    wait 0.05;

    if (self.money > 5000) {
    self.money = 5000;
    }
    }
    }
    [/php]

  3. #3
    CainFool's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Posts
    313
    Reputation
    11
    Thanks
    146
    My Mood
    Angelic
    Not allowed to double post.