Jump to content
  • 0

Vote Point NPC Problem


PapaZola

Question


  • Group:  Members
  • Topic Count:  318
  • Topics Per Day:  0.07
  • Content Count:  925
  • Reputation:   32
  • Joined:  12/05/11
  • Last Seen:  

celestian,75,62,4 script VoteEtc 629,{

setarray @vote_item[0], 7089,7086; // Item ID

setarray @vote_item_count[0], 1 ,1; // Item Count wich will be given

setarray @vote_cost[0], 1000 ,700; // Cost in Vote Points

set @min_vote, 0; // minimum count on Vote Points to see the Item List

set @npcname$,"[^ff0000VOTE POINT ETC^000000]";

query_sql ("SELECT `point` FROM `vote_point` WHERE `account_id` = '"+getcharid(3)+"'", @vote);

mes @npcname$;

mes "You have ^ff0000"+@vote+"^000000 Vote Points!";

if( @vote < @min_vote ) {

mes "^ff0000You will need "+@min_vote+" or more Vote Points to trade them with me!^000000";

close;

}

if (select("Trade my Points!","Cancel~") == 2)

close;

next;

mes "[^ff0000List^000000]";

mes "^0000ffItem^000000 = ^00aa00Cost^000000";

for( set .@i, 0; .@i < getarraysize(@vote_item); set .@i, .@i + 1 ) {

mes "^0000ff"+@vote_item_count[.@i]+"x "+getitemname(@vote_item[.@i])+"^000000 = ^00aa00"+@vote_cost[.@i]+"^000000";

if( .@i < 1 )

set .@menu$, getitemname(@vote_item[.@i]);

else

set .@menu$, .@menu$+":"+getitemname(@vote_item[.@i]);

}

next;

select(.@menu$);

set @choice, @menu - 1;

mes @npcname$;

if( @vote_cost[@choice] > @vote ) {

mes "^ff0000You dont have enought Vote Point for "+@vote_item_count[@choice]+"x '"+getitemname(@vote_item[@choice])+"' :/^000000";

close;

}

mes "Are u realy sure to trade "+@vote_item_count[@choice]+"x '^ff0000"+getitemname(@vote_item[@choice])+"^000000' for ^00aa00"+@vote_cost[@choice]+"^000000 Vote Points?";

if(select("No! Cancel!:Yes, Trade me!") == 1 ) {

mes "^ff0000Trade was canceled~^000000";

close;

}

set .@new, @vote - @vote_cost[@choice];

if( .@new < 0 ) // safty first..

set .@new, 0;

query_sql("UPDATE `vote_point` SET `point` = '"+.@new+"' WHERE `account_id` = '"+getcharid(3)+"'");

getitem @vote_item[@choice], @vote_item_count[@choice];

mes "^00aa00Trade was Successfull ^_^ Hope to see u again =)!^000000";

close;

}

i got a problem with this npc

at NPC A i added 10 wings

and at this npc i add 2 ETC item

but when i want trade my points i see on this npc got sell wing also

how i can fix this problem?

Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  107
  • Reputation:   91
  • Joined:  01/19/12
  • Last Seen:  

Hi,

Replace this line:

query_sql ("SELECT `point` FROM `vote_point` WHERE `account_id` = '"+getcharid(3)+"'", @vote);

With this:

query_sql ("SELECT sum(`point`) pts FROM `vote_point` WHERE `account_id` = " + getcharid(3), @vote);

Why?, because sum will always return 1 result, if there are no results, @vote will be 0.

After that, use @vote[0] because that value is a array, not a integer.

Regards,

Myzter

PD: Try to use CODEBOX instead CODE, it's more readable. ;)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  318
  • Topics Per Day:  0.07
  • Content Count:  925
  • Reputation:   32
  • Joined:  12/05/11
  • Last Seen:  

thx sir Mizer

Link to comment
Share on other sites

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.

×
×
  • Create New...