A way to read storage items of the invoking player

Echoes

New member
Messages
68
Points
0
Age
33
Github
Maxitotito
Emulator
Hello,

I was wondering, is there a way to use somethin alike countitem() but for storage items instead of the inventory items?

For example, I want to count how many Iron ore does the invoking character has in their storage, and return the number to the dialog the NPC is having; I think something with query_mysql() may be useful.

Thank you in advance.

 
query_sql("SELECT amount FROM storage WHERE char_id = " + getcharid(0) + " AND id = " + .@item_id, .@amount);
mes "You have " + .@amount + " " + getitemname(.@item_id) + " in your storage!";
close;


?

 
query_sql("SELECT amount FROM storage WHERE char_id = " + getcharid(0) + " AND id = " + .@item_id, .@amount);
mes "You have " + .@amount + " " + getitemname(.@item_id) + " in your storage!";
close;


?
Yeah, something like that.

I will test it when I can, thank you!

 
query_sql("SELECT amount FROM storage WHERE char_id = " + getcharid(0) + " AND id = " + .@item_id, .@amount);
mes "You have " + .@amount + " " + getitemname(.@item_id) + " in your storage!";
close;


?
Code:
[COLOR=#000000]query_sql[/COLOR][COLOR=#666600](sprintf([/COLOR][COLOR=#008800]"SELECT amount FROM storage WHERE account_id='%d'[/COLOR][COLOR=#008800] AND nameid='%d'", getcharid(3), .@item_id)[/COLOR][COLOR=#666600],[/COLOR][COLOR=#000000] [/COLOR][COLOR=#666600].[/COLOR][COLOR=#006666]@amount[/COLOR][COLOR=#666600]);[/COLOR]
 
Thank you for the replies @Kubix, @Dastgir.

May I ask then, how can I update the value of something (ingame) without making the invoking character to relog?

With my example, I erased 2 Iron Ores found in the storage of the character, and I can see that data update in the database, but ingame there are still that 2 Iron ores in the storage. Relogging fix this issue.

 
Last edited by a moderator:
Back
Top