Jump to content
  • 0

Problem with getd in a dynamic quest shop.


Question

Posted (edited)

Hello, I'm trying to make a dynamic quest shop(Don't want to take a already made script), but I'm having a little trouble by making the getd get the right value.

 

 

function x {
    [...]
    setarray .@j[0],535,1,536,1;
    copyarray getd(".q_"+getarg(0)+"[0]"),.@j[0],getarraysize(.@j); // beeing getarg(0) = 535
    [...]
}
 
OnBuyItem:
    [...]
    for(set .@i,2; .@i < getarraysize(getd(".q_"+@bought_nameid+"")); set .@i,.@i + 2) {
        mes ""+getd(".q_"+@bought_nameid+"["+.@i+"+2]")+"x "+getitemname(getd(".q_"+@bought_nameid+"["+.@i+"+1]")); // Beeing @bought_nameid = 535
    }
    [...]

 

So the problem is that it dosen't get the values of [3] and [4], only from [0]. Instead of beeing 1x Ice Cream(536) it's 535x Pumpkins.(OnBuyItem).

 

Any help is welcome.

Edited by BRDominik

7 answers to this question

Recommended Posts

Posted

try this

http://pastebin.com/raw.php?i=xMCguEAW

 

you stored the array data wrongly..

    for(set .@i,0; .@i < getargcount(); set .@i,.@i + 1) {  // should start by 0 ..not 2
        setarray .@j[.@i],getarg(.@i);
    }
mes "Quest: "+getd(".q_"+@bought_nameid+"[1]")+"x "+getitemname(getd(".q_"+@bought_nameid+"[0]"));// show wrong index
mes ""+getd(".q_"+@bought_nameid+"["+(.@i+1)+"]")+"x "+getitemname(getd(".q_"+@bought_nameid+"["+(.@i)+"]"))+""; // show wrong index
  • Upvote 1
Posted

i believe this..

getd(".q_"+@bought_nameid+"["+.@i+"+2]")
getd(".q_"+@bought_nameid+"["+.@i+"+1]")

 

should be

getd(".q_"+@bought_nameid+"["+( .@i + 1 )+"]")
getd(".q_"+@bought_nameid+"["+( .@i + 2 )+"]")
Posted (edited)

i believe this..

getd(".q_"+@bought_nameid+"["+.@i+"+2]")
getd(".q_"+@bought_nameid+"["+.@i+"+1]")

 

should be

getd(".q_"+@bought_nameid+"["+( .@i + 1 )+"]")
getd(".q_"+@bought_nameid+"["+( .@i + 2 )+"]")

Yeah, I just realized that. =/ Im going to try and see if that works. Thx

 

@edit The problem persist. Oh I forgot to say whats the real problem.  /whisp

 

So the problem is that it dosen't get the values of [3] and [4], only from [0]. Instead of beeing 1x Ice Cream(536) it's 535x Pumpkins

Edited by BRDominik
Posted (edited)

perhap you can show your full script so that i can take a look on it ... ? it will be more easier to duplicate ur problems and fix it.

Sure. I actually made, because I was going to post on a brazilian forum. One sec.

Edited by BRDominik
Posted (edited)

hmm ? i dont see any function X ? and ur script alot of things are missing...

  • shop are not called..
  •  
  • no items to be purchase...
  •  
  • details like how you going to work on this..
  •  

your script are basically just copied from

trunk/npc/custom/quests/quest_shop.txt

Im trying to make that on my own, the only part that I 'copied' was the getd area.

 

And I posted the wrong script(Yay...).

 

 
prontera,142,170,5    script    Quests    965,{
function Add;
callshop "qshop",1;
npcshopattach "qshop";
end;
 
OnInit:
    // Não mexa em nada acima disso
    // Add(Reward ID,Reward Amount,Required ID,Required Amount,{,...});
    Add(535,1,536,1);
    npcshopdelitem "qshop",537;
    end;
 
OnBuyItem:
    if(getarraysize(@bought_nameid) > 1) {
        mes "Por favor escolha só um item.";
        close;
    }
    mes strnpcinfo(1);
    mes "Quest: "+getd(".q_"+@bought_nameid+"[1]")+"x "+getitemname(getd(".q_"+@bought_nameid+"[0]"));
    mes "Requerimentos:";
    for(set .@i,2; .@i < getarraysize(getd(".q_"+@bought_nameid+"")); set .@i,.@i + 2) {
        mes ""+getd(".q_"+@bought_nameid+"["+(.@i+2)+"]")+"x "+getitemname(getd(".q_"+@bought_nameid+"["+(.@i+1)+"]"))+"";
        if(.@i%8 == 0) next;
    }
    close;
 
function    Add    {
    if(getargcount()%2) { message "Zawe","Something went wrong. Theres is something wrong with the Code."; return; }
    for(set .@i,0; .@i < getargcount(); set .@i,.@i + 1) {
        if(.@i%2 == 0) {
            if(getitemname(getarg(.@i)) == "null") { message "Zawe","Something went wrong. One of the Items ID do not exist."; return; }
        }
    }
    for(set .@i,0; .@i < getargcount(); set .@i,.@i + 1) {
        setarray .@j[.@i],getarg(.@i);
        message "Zawe",getarg(.@i);
    }
    copyarray getd(".q_"+getarg(0)+"[0]"),.@j[0],getarraysize(.@j);
    npcshopadditem "qshop",getarg(0),1;
    return;
}
}
 
-    shop    qshop    -1,537:-1
Edited by BRDominik

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...