Can someone tell me why my VP script doesnt work?

Results 1 to 9 of 9
  1. #1
    Valued Member PerfectEnding is offline
    MemberRank
    Jul 2013 Join Date
    104Posts

    Can someone tell me why my VP script doesnt work?

    When I make a selection, nothing happens. Also no bat errors? The npc just closes.
    Spoiler:

    var coconutid = 4000465; var lidiumid = 4010007;
    var price = [1, 1, 6];
    var maxstats = false;
    var status = -1;
    var PACKETALERTER;
    var maxstatus = false;
    var max = 32767;


    function start() {
    action(1,0,0);
    }


    function action(m,t,s) {
    if (m != 1) {
    cm.dispose();
    return;
    } else {
    status++;
    }
    if (status == 0) {
    cm.sendSimple("#eHello #b#h ##k, i am the voting points npc. Have you voted for the server ? If so, you can spend your points here. If you just voted and have not received your points, you most likely didn't disconnect. So, would you like to trade some points?\r\n\r\nYou currently have #b"+cm.getVPoints()+" #kvoting points.\r\n\r\n#r#L0#1 vote point - 15 coconuts#v"+coconutid+"##l\r\n#L1#1 vote point - 5 lidium#v"+lidiumid+"##l\r\n#L2#6 vote points - Max any stats you want (str,int,dex,luk)");
    } else if (status == 1) {
    if (cm.getVPoints() >= 1) {
    if (s == 0) {
    cm.gainItem(coconutid, 15);
    cm.gainVPoints(-price[s]);
    cm.sendOk("#eThanks! 1 point has been deducted from your vote points!");
    } else if (s == 1) {
    cm.gainItem(lidiumid, 5);
    cm.gainVPoints(-price[s]);
    cm.sendOk("#eThanks! 1 point has been deducted from your vote points!");
    } else if (s == 2) {
    if (cm.getVPoints() >= 6) {
    maxstatus = true;
    //cm.sendOk("#eThis feature has been disabled for now as i didn't have time to fix it. It will be fixed very soon!\r\n\r\n#b- 26/01/2012");
    cm.sendSimple("#eWhich stats would you like to max?\r\n\r\n#r#L15#Str#l\r\n#L16#Int#l\r\n#L17#Dex#l\r\n#L18#Luk#l");
    } else {
    cm.sendOk("#eHEY. We don't give free stats. Sorry.");
    cm.dispose();
    }
    }
    } else {
    cm.sendOk("#eLooks like you're missing some voting points for that!");
    cm.dispose();
    }
    } else if (status == 2) {
    if (maxstatus == true) {
    if (s == 15) {
    if (cm.getPlayer().getStat().getStr() >= 32767) {
    cm.gainVPoints(-price[2]);
    cm.getPlayer().getStat().setStr(max);
    cm.sendOk("#eYour strength has been maxed!");
    cm.dispose();
    } else {
    cm.sendOk("#eYour strength has already been maxed!");
    cm.dispose();
    }
    } else if (s == 16) {
    if (cm.getPlayer().getStat().getInt() >= 32767) {
    cm.gainVPoints(-price[2]);
    ccm.getPlayer().getStat().setInt(max);
    cm.sendOk("#eYour Intelligence has been maxed!");
    cm.dispose();
    } else {
    cm.sendOk("#eYour intelligence has already been maxed!");
    cm.dispose();
    }
    } else if (s == 17) {
    if (cm.getPlayer().getStat().getDex() >= 32767) {
    cm.gainVPoints(-price[2]);
    cm.getPlayer().getStat().setDex(max);
    cm.sendOk("#eYour Dexterity has been maxed!");
    cm.dispose();
    } else {
    cm.sendOK("#eYour Dexterity has already been maxed!");
    cm.dispose();
    }
    } else if (s == 18) {
    if (cm.getPlayer().getStat().getStr() >= 32767) {
    cm.gainVPoints(-price[2]);
    cm.getPlayer().getStat().setLuk(max);
    cm.sendOk("#eYour Luck has been maxed!");
    cm.dispose();
    } else {
    cm.sendOk("#eYour luk has already been maxed!");
    cm.dispose();
    }
    }
    } else {
    for (i = 0; i > 100; i++) {
    PACKETALERTER += "INVALID_, PACKETALERT. print DO NOT PACKET EDIT.";
    }
    cm.sendOk(PACKETALERTER);
    }
    }
    cm.dispose();
    }


  2. #2
    Account Upgraded | Title Enabled! Las Systos is offline
    MemberRank
    Mar 2015 Join Date
    NetherlandsLocation
    238Posts

    Re: Can someone tell me why my VP script doesnt work?

    Use code tags next time please,
    There is a dispose(); at the very end that doesnt belong there, just place that one after cm.sendOk(PACKETALERTER);

  3. #3
    :l Cygnus is offline
    MemberRank
    Mar 2015 Join Date
    f425Location
    237Posts

    Re: Can someone tell me why my VP script doesnt work?

    PHP Code:
    var coconutid 4000465;var lidiumid 4010007;
    var 
    price = [116];
    var 
    max 32767;
    status 0;


    function 
    start() {
        
    cm.sendSimple("#eHello #b#h ##k, i am the voting points npc. Have you voted for the server ? If so, you can spend your points here. If you just voted and have not received your points, you most likely didn't disconnect. So, would you like to trade some points?\r\n\r\nYou currently have #b"+cm.getVPoints()+" #kvoting points.\r\n\r\n#r#L0#1 vote point - 15 coconuts#v"+coconutid+"##l\r\n#L1#1 vote point - 5 lidium#v"+lidiumid+"##l\r\n#L2#6 vote points - Max any stats you want (str,int,dex,luk)#l");
    }


    function 
    action(mode,type,selection) {
        if (
    mode 1) {
            
    cm.dispose();
            return;
        } else 
            
    status++;
        if (
    status == 1) {
            if (
    cm.getVPoints() > 0) {
                if (
    selection == 0) {
                    
    cm.gainItem(coconutid15);
                    
    cm.gainVPoints(-price[s]);
                    
    cm.sendOk("#eThanks! 1 point has been deducted from your vote points!");    
                    
    cm.dispose();
                } else if (
    selection == 1) {
                    
    cm.gainItem(lidiumid5);
                    
    cm.gainVPoints(-price[s]);
                    
    cm.sendOk("#eThanks! 1 point has been deducted from your vote points!");
                    
    cm.dispose();
                } else if (
    selection == 2) {
                    if (
    cm.getVPoints() > price[2]) {
                        
    cm.sendSimple("#eWhich stats would you like to max?\r\n\r\n#r#L15#Str#l\r\n#L16#Int#l\r\n#L17#Dex#l\r\n#L18#Luk#l");
                    } else {
                        
    cm.sendOk("#eHEY. We don't give free stats. Sorry.");
                        
    cm.dispose();
                    }
                }
            } else {
                
    cm.sendOk("#eLooks like you're missing some voting points for that!");
                
    cm.dispose();
            }
        } else if (
    status == 2) {
            if (
    cm.getVPoints >= price[2]) {
                if (
    selection == 15) {
                    if (
    cm.getPlayer().getStat().getStr() < max) {
                        
    cm.gainVPoints(-price[2]);
                        
    cm.getPlayer().getStat().setStr(max);
                        
    cm.sendOk("#eYour strength has been maxed!");    
                    } else {
                        
    cm.sendOk("#eYour strength has already been maxed!");
                    }
                } else if (
    selection == 16) {
                    if (
    cm.getPlayer().getStat().getInt() < max) {
                        
    cm.gainVPoints(-price[2]);
                        
    cm.getPlayer().getStat().setInt(max);
                        
    cm.sendOk("#eYour Intelligence has been maxed!");                    
                    } else {
                        
    cm.sendOk("#eYour intelligence has already been maxed!");
                    }
                } else if (
    selection == 17) {
                    if (
    cm.getPlayer().getStat().getDex() < max) {
                        
    cm.gainVPoints(-price[2]);
                        
    cm.getPlayer().getStat().setDex(max);
                        
    cm.sendOk("#eYour Dexterity has been maxed!");    
                    } else {
                        
    cm.sendOK("#eYour Dexterity has already been maxed!");
                    }        
                } else if (
    selection == 18) {
                    if (
    cm.getPlayer().getStat().getLuk() < max) {
                        
    cm.gainVPoints(-price[2]);
                        
    cm.getPlayer().getStat().setLuk(max);
                        
    cm.sendOk("#eYour Luck has been maxed!");        
                    } else {
                        
    cm.sendOk("#eYour luk has already been maxed!");
                    }
                }
            } 
    cm.dispose();
        }

    Rewrote the script for you.

  4. #4
    Valued Member PerfectEnding is offline
    MemberRank
    Jul 2013 Join Date
    104Posts

    Re: Can someone tell me why my VP script doesnt work?

    Quote Originally Posted by Cygnus View Post
    Rewrote the script for you.
    Quote Originally Posted by las systos View Post
    Use code tags next time please,
    There is a dispose(); at the very end that doesnt belong there, just place that one after cm.sendOk(PACKETALERTER);
    Thanks for the help you two! @Cygnus, how come its saying [s] isnt defined?

    How do i remove max stat?
    Last edited by PerfectEnding; 18-08-15 at 04:46 AM.

  5. #5
    Account Upgraded | Title Enabled! Las Systos is offline
    MemberRank
    Mar 2015 Join Date
    NetherlandsLocation
    238Posts

    Re: Can someone tell me why my VP script doesnt work?

    Quote Originally Posted by PerfectEnding View Post
    Thanks for the help you two! @Cygnus, how come its saying [s] isnt defined?

    How do i remove max stat?
    thats because he changed function action to (mode, type, selection) instead of (m, t, s)
    just change [s] to [selection]

    and what do you mean with remove max stat?

  6. #6
    :l Cygnus is offline
    MemberRank
    Mar 2015 Join Date
    f425Location
    237Posts

    Re: Can someone tell me why my VP script doesnt work?

    As las systos said, I defined selection as selection instead of s. You'd have to replace the [s] with [selection]. Also, if by removing max stat you mean the client sided limit of 32767, you'd need to hack the client. In the client, each stat is stored as a 16-bit signed integer, meaning you can't display values outside of the range of a 16-bit signed int (ranges from -32768 to 32767). You can store higher numbers as stats server sidedly, but you couldn't display them in the client as is.

  7. #7
    Valued Member PerfectEnding is offline
    MemberRank
    Jul 2013 Join Date
    104Posts

    Re: Can someone tell me why my VP script doesnt work?

    Quote Originally Posted by Cygnus View Post
    As las systos said, I defined selection as selection instead of s. You'd have to replace the [s] with [selection]. Also, if by removing max stat you mean the client sided limit of 32767, you'd need to hack the client. In the client, each stat is stored as a 16-bit signed integer, meaning you can't display values outside of the range of a 16-bit signed int (ranges from -32768 to 32767). You can store higher numbers as stats server sidedly, but you couldn't display them in the client as is.
    Quote Originally Posted by las systos View Post
    thats because he changed function action to (mode, type, selection) instead of (m, t, s)
    just change [s] to [selection]

    and what do you mean with remove max stat?

    Thx for reply. I just noticed about the [s] also when i say remove max stat I wan to just remove the option to max stat from npc. I wan to just add more item to sell to player. Everytime I try to remove, npc breaks or doesnt work again even though I closed it off with } properly

  8. #8
    Account Upgraded | Title Enabled! Las Systos is offline
    MemberRank
    Mar 2015 Join Date
    NetherlandsLocation
    238Posts

    Re: Can someone tell me why my VP script doesnt work?

    Well thats like 70% of the script, but here you go I guess:
    Code:
    var coconutid = 4000465;var lidiumid = 4010007;
    var price = [1, 1];
    var status = 0;
    
    
    
    
    function start() {
        cm.sendSimple("#eHello #b#h ##k, i am the voting points npc. Have you voted for the server ? If so, you can spend your points here. If you just voted and have not received your points, you most likely didn't disconnect. So, would you like to trade some points?\r\n\r\nYou currently have #b"+cm.getVPoints()+" #kvoting points.\r\n\r\n#r#L0#1 vote point - 15 coconuts#v"+coconutid+"##l\r\n#L1#1 vote point - 5 lidium#v"+lidiumid+"##l");
    }
    
    
    
    
    function action(mode, type, selection) {
        if (mode < 1) {
            cm.dispose();
            return;
        } else 
            status++;
        if (status === 1) {
            if (cm.getVPoints() > 0) {
                if (selection === 0) {
                    cm.gainItem(coconutid, 15);
                    cm.gainVPoints(-price[selection]);
                    cm.sendOk("#eThanks! 1 point has been deducted from your vote points!");    
                    cm.dispose();
                } else if (selection === 1) {
                    cm.gainItem(lidiumid, 5);
                    cm.gainVPoints(-price[selection]);
                    cm.sendOk("#eThanks! 1 point has been deducted from your vote points!");
                    cm.dispose();
                }
            } else {
                cm.sendOk("#eLooks like you're missing some voting points for that!");
                cm.dispose();
            }
        }
    }

  9. #9
    Valued Member PerfectEnding is offline
    MemberRank
    Jul 2013 Join Date
    104Posts

    Re: Can someone tell me why my VP script doesnt work?

    Quote Originally Posted by las systos View Post
    Well thats like 70% of the script, but here you go I guess:
    can teach me how to set requirement for each item i add in that 2vp+? I read this line and not every item is only 1 vote point. Im thinking it might sell even to people without right amount?

    if (cm.getVPoints() > 0) {





Advertisement