LithiumFire Posted December 5, 2015 Group: Members Topic Count: 12 Topics Per Day: 0.00 Content Count: 28 Reputation: 3 Joined: 08/06/12 Last Seen: December 8, 2017 Share Posted December 5, 2015 (edited) Hello everyone, I would like a VIP time shop that charges cash points. I think it's pretty straightforward. To make things a lot simplier, it should only make players chonce among two options of VIP time: 7 days 30 days The Cashpoint cost should be configurable for each option (variables probably) something like: var7days = 10; // <-- 10 would be Cash points var30days = 20; Very important: On insufficient cashpoints: Display an error message and don't give the VIP time of course. The look and location of the NPC doesn't matter, I can change this later. It would be nice also, if this NPC could be bound to certain atCommand, e.g. "@vipshop" Thanks a lot in advance. Greetings! Edited December 5, 2015 by LithiumFire Quote Link to comment Share on other sites More sharing options...
1 AnnieRuru Posted December 8, 2015 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 2044 Reputation: 682 Joined: 10/09/12 Last Seen: December 20, 2020 Share Posted December 8, 2015 (edited) you didn't do anything wrong ... why ? because Emistry script isn't working ... try this, full complete script function script timeleft__ { if ( ( .@left = getarg(0) ) <= 0 ) return getarg(0); .@day = .@left / 86400; .@hour = .@left % 86400 / 3600; .@min = .@left % 3600 / 60; .@sec = .@left % 60; if ( .@day ) return .@day +" day "+ .@hour +" hour"; else if ( .@hour ) return .@hour +" hour "+ .@min +" min"; else if ( .@min ) return .@min +" min "+ .@sec +" sec"; else return .@sec +" sec"; } - shop vipshop#7 -1,501:100 - shop vipshop#30 -1,501:100 - script vipnpc FAKE_NPC,{ OnInit: bindatcmd "vipshop", strnpcinfo(0)+"::Onvipshop"; end; Onvipshop: if ( #vipshop == 1 ) callshop "vipshop#7", 1; else if ( #vipshop == 2 ) callshop "vipshop#30", 1; else { mes "which vip status do you want to buy ?"; mes "vip 7 days = 10 Cash points"; mes "vip 30 days = 20 Cash points"; next; if ( select ( "Vip 7 Days", "Vip 30 Days" ) == 1 ) { if ( #CASHPOINTS < 10 ) { mes "you don't have enough Cash points"; close; } mes "Thanks for purchasing !"; #vipshop = 1; #CASHPOINTS -= 10; addtimer 7*24*60*60*1000, strnpcinfo(0)+"::OnTimeUp"; #viptimeleft = 7*24*60*60 + gettimetick(2); close; } else { if ( #CASHPOINTS < 20 ) { mes "you don't have enough Cash points"; close; } mes "Thanks for purchasing !"; #vipshop = 2; #CASHPOINTS -= 20; // addtimer 30*24*60*60*1000, strnpcinfo(0)+"::OnTimeUp"; // over integer limit #viptimeleft = 30*24*60*60 + gettimetick(2); close; } } dispbottom "You currently have "+ #CASHPOINTS +" Cash points .Expire in "+ callfunc( "timeleft__", #viptimeleft - gettimetick(2) )+"."; end; OnPCLoginEvent: if ( #viptimeleft < gettimetick(2) ) addtimer 1, strnpcinfo(0)+"::OnTimeUp"; // sometimes doevent doesn't work else if ( #viptimeleft - gettimetick(2) < 2147483 ) // don't execute addtimer if over integer limit addtimer ( #viptimeleft - gettimetick(2) )*1000, strnpcinfo(0)+"::OnTimeUp"; end; OnTimeUp: #viptimeleft = #vipshop = 0; end; } - script vipnpc#7 FAKE_NPC,{ OnInit: function addshopitem { npcshopdelitem "vipshop#7", 501; .@count = getargcount(); for ( .@i = 0; .@i < .@count; .@i++ ) { if ( .@i % 2 == 0 ) .itemid[ .@i /2 ] = getarg( .@i ); else { .itemcost[ .@i /2 ] = getarg( .@i ); npcshopadditem "vipshop#7", .itemid[ .@i /2 ], .itemcost[ .@i /2 ]; } } } addshopitem // adds shop items here for vip#7 501,10, 502,20, 503,30, 504,40, 505,50; npcshopattach "vipshop#7"; .@itemsize = getarraysize( .itemid ); for ( .@i = 0; .@i < .@itemsize; .@i++ ) .itemcost[ .itemid[.@i] ] = .itemcost[.@i]; end; OnBuyItem: if ( !@bought_quantity ) end; .@size = getarraysize( @bought_nameid ); for ( .@i = 0; .@i < .@size; .@i++ ) .@itemcost += .itemcost[ @bought_nameid[.@i] ] * @bought_quantity[.@i]; if ( .@itemcost > #CASHPOINTS ) { mes "you don't have enough Cash points"; close; } if ( !checkweight2( @bought_nameid, @bought_quantity ) ) { mes "you can't carry all these items !"; close; } #CASHPOINTS -= .@itemcost; for ( .@i = 0; .@i < .@size; .@i++ ) getitem @bought_nameid[.@i], @bought_quantity[.@i]; end; } - script vipnpc#30 FAKE_NPC,{ OnInit: function addshopitem { npcshopdelitem "vipshop#30", 501; .@count = getargcount(); for ( .@i = 0; .@i < .@count; .@i++ ) { if ( .@i % 2 == 0 ) .itemid[ .@i /2 ] = getarg( .@i ); else { .itemcost[ .@i /2 ] = getarg( .@i ); npcshopadditem "vipshop#30", .itemid[ .@i /2 ], .itemcost[ .@i /2 ]; } } } addshopitem // adds shop items here for vip#30 501,5, 502,10, 503,15, 504,20, 505,25; npcshopattach "vipshop#30"; .@itemsize = getarraysize( .itemid ); for ( .@i = 0; .@i < .@itemsize; .@i++ ) .itemcost[ .itemid[.@i] ] = .itemcost[.@i]; end; OnBuyItem: if ( !@bought_quantity ) end; .@size = getarraysize( @bought_nameid ); for ( .@i = 0; .@i < .@size; .@i++ ) .@itemcost += .itemcost[ @bought_nameid[.@i] ] * @bought_quantity[.@i]; if ( .@itemcost > #CASHPOINTS ) { mes "you don't have enough Cash points"; close; } if ( !checkweight2( @bought_nameid, @bought_quantity ) ) { mes "you can't carry all these items !"; close; } #CASHPOINTS -= .@itemcost; for ( .@i = 0; .@i < .@size; .@i++ ) getitem @bought_nameid[.@i], @bought_quantity[.@i]; end; } Edited December 8, 2015 by AnnieRuru 1 1 Quote Link to comment Share on other sites More sharing options...
0 Emistry Posted December 6, 2015 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: 19 hours ago Share Posted December 6, 2015 something like this ? i havent test it. - script atcmd_example 757,{ OnAtcommand: mes "Buy VIP ?"; switch ( select( "VIP 7 Days","VIP 30 Days" ) ) { // callsub L_cashpoint,<day>,<cash>; case 1: callsub L_cashpoint,7,10; break; case 1: callsub L_cashpoint,30,20; break; default: break; } close; L_cashpoint: .@day = getarg( 0,0 ); .@cash = getarg( 1,0 ); mes .@day+" days VIP - "+.@cash+" cash"; if ( #CASHPOINTS >= .@cash ) { if ( select( "Purchase","Cancel" ) == 1 ) { #CASHPOINTS -= .@cash; } } return; OnInit: bindatcmd "vipshop",strnpcinfo(3)+"::OnAtcommand"; end; } Quote Link to comment Share on other sites More sharing options...
0 LithiumFire Posted December 8, 2015 Group: Members Topic Count: 12 Topics Per Day: 0.00 Content Count: 28 Reputation: 3 Joined: 08/06/12 Last Seen: December 8, 2017 Author Share Posted December 8, 2015 Yeah, looks right! Thank you, I'll test it ASAP. Again, thanks. I haven't been able to make it work. The script loads but it keeps saying "@vipshop" is Unknown command. What am I doing wrong? Quote Link to comment Share on other sites More sharing options...
0 PandaLovesHamster Posted December 8, 2015 Group: Members Topic Count: 51 Topics Per Day: 0.01 Content Count: 452 Reputation: 34 Joined: 12/18/14 Last Seen: May 30, 2016 Share Posted December 8, 2015 Check map server for errors. Quote Link to comment Share on other sites More sharing options...
0 LithiumFire Posted December 8, 2015 Group: Members Topic Count: 12 Topics Per Day: 0.00 Content Count: 28 Reputation: 3 Joined: 08/06/12 Last Seen: December 8, 2017 Author Share Posted December 8, 2015 you didn't do anything wrong ... why ? because Emistry script isn't working ... try this, full complete script function script timeleft__ { if ( ( .@left = getarg(0) ) <= 0 ) return getarg(0); .@day = .@left / 86400; .@hour = .@left % 86400 / 3600; .@min = .@left % 3600 / 60; .@sec = .@left % 60; if ( .@day ) return .@day +" day "+ .@hour +" hour"; else if ( .@hour ) return .@hour +" hour "+ .@min +" min"; else if ( .@min ) return .@min +" min "+ .@sec +" sec"; else return .@sec +" sec"; } - shop vipshop#7 -1,501:100 - shop vipshop#30 -1,501:100 - script vipnpc FAKE_NPC,{ OnInit: bindatcmd "vipshop", strnpcinfo(0)+"::Onvipshop"; end; Onvipshop: if ( #vipshop == 1 ) callshop "vipshop#7", 1; else if ( #vipshop == 2 ) callshop "vipshop#30", 1; else { mes "which vip status do you want to buy ?"; mes "vip 7 days = 10 Cash points"; mes "vip 30 days = 20 Cash points"; next; if ( select ( "Vip 7 Days", "Vip 30 Days" ) == 1 ) { if ( #CASHPOINTS < 10 ) { mes "you don't have enough Cash points"; close; } mes "Thanks for purchasing !"; #vipshop = 1; #CASHPOINTS -= 10; addtimer 7*24*60*60*1000, strnpcinfo(0)+"::OnTimeUp"; #viptimeleft = 7*24*60*60 + gettimetick(2); close; } else { if ( #CASHPOINTS < 20 ) { mes "you don't have enough Cash points"; close; } mes "Thanks for purchasing !"; #vipshop = 2; #CASHPOINTS -= 20; // addtimer 30*24*60*60*1000, strnpcinfo(0)+"::OnTimeUp"; // over integer limit #viptimeleft = 30*24*60*60 + gettimetick(2); close; } } dispbottom "You currently have "+ #CASHPOINTS +" Cash points .Expire in "+ callfunc( "timeleft__", #viptimeleft - gettimetick(2) )+"."; end; OnPCLoginEvent: if ( #viptimeleft < gettimetick(2) ) addtimer 1, strnpcinfo(0)+"::OnTimeUp"; // sometimes doevent doesn't work else if ( #viptimeleft - gettimetick(2) < 2147483 ) // don't execute addtimer if over integer limit addtimer ( #viptimeleft - gettimetick(2) )*1000, strnpcinfo(0)+"::OnTimeUp"; end; OnTimeUp: #viptimeleft = #vipshop = 0; end; } - script vipnpc#7 FAKE_NPC,{ OnInit: function addshopitem { npcshopdelitem "vipshop#7", 501; .@count = getargcount(); for ( .@i = 0; .@i < .@count; .@i++ ) { if ( .@i % 2 == 0 ) .itemid[ .@i /2 ] = getarg( .@i ); else { .itemcost[ .@i /2 ] = getarg( .@i ); npcshopadditem "vipshop#7", .itemid[ .@i /2 ], .itemcost[ .@i /2 ]; } } } addshopitem // adds shop items here for vip#7 501,10, 502,20, 503,30, 504,40, 505,50; npcshopattach "vipshop#7"; .@itemsize = getarraysize( .itemid ); for ( .@i = 0; .@i < .@itemsize; .@i++ ) .itemcost[ .itemid[.@i] ] = .itemcost[.@i]; end; OnBuyItem: if ( !@bought_quantity ) end; .@size = getarraysize( @bought_nameid ); for ( .@i = 0; .@i < .@size; .@i++ ) .@itemcost += .itemcost[ @bought_nameid[.@i] ] * @bought_quantity[.@i]; if ( .@itemcost > #CASHPOINTS ) { mes "you don't have enough Cash points"; close; } if ( !checkweight2( @bought_nameid, @bought_quantity ) ) { mes "you can't carry all these items !"; close; } #CASHPOINTS -= .@itemcost; for ( .@i = 0; .@i < .@size; .@i++ ) getitem @bought_nameid[.@i], @bought_quantity[.@i]; end; } - script vipnpc#30 FAKE_NPC,{ OnInit: function addshopitem { npcshopdelitem "vipshop#30", 501; .@count = getargcount(); for ( .@i = 0; .@i < .@count; .@i++ ) { if ( .@i % 2 == 0 ) .itemid[ .@i /2 ] = getarg( .@i ); else { .itemcost[ .@i /2 ] = getarg( .@i ); npcshopadditem "vipshop#30", .itemid[ .@i /2 ], .itemcost[ .@i /2 ]; } } } addshopitem // adds shop items here for vip#30 501,5, 502,10, 503,15, 504,20, 505,25; npcshopattach "vipshop#30"; .@itemsize = getarraysize( .itemid ); for ( .@i = 0; .@i < .@itemsize; .@i++ ) .itemcost[ .itemid[.@i] ] = .itemcost[.@i]; end; OnBuyItem: if ( !@bought_quantity ) end; .@size = getarraysize( @bought_nameid ); for ( .@i = 0; .@i < .@size; .@i++ ) .@itemcost += .itemcost[ @bought_nameid[.@i] ] * @bought_quantity[.@i]; if ( .@itemcost > #CASHPOINTS ) { mes "you don't have enough Cash points"; close; } if ( !checkweight2( @bought_nameid, @bought_quantity ) ) { mes "you can't carry all these items !"; close; } #CASHPOINTS -= .@itemcost; for ( .@i = 0; .@i < .@size; .@i++ ) getitem @bought_nameid[.@i], @bought_quantity[.@i]; end; } All right, thank you! I'll test it! Quote Link to comment Share on other sites More sharing options...
Question
LithiumFire
Hello everyone,
I would like a VIP time shop that charges cash points. I think it's pretty straightforward.
To make things a lot simplier, it should only make players chonce among two options of VIP time:
The Cashpoint cost should be configurable for each option (variables probably) something like:
var7days = 10; // <-- 10 would be Cash points
var30days = 20;
Very important: On insufficient cashpoints: Display an error message and don't give the VIP time of course.
The look and location of the NPC doesn't matter, I can change this later.
It would be nice also, if this NPC could be bound to certain atCommand, e.g. "@vipshop"
Thanks a lot in advance.
Greetings!
Edited by LithiumFireLink to comment
Share on other sites
5 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.