Feilor Posted June 8, 2015 Group: Members Topic Count: 37 Topics Per Day: 0.01 Content Count: 135 Reputation: 17 Joined: 12/31/11 Last Seen: January 11 Share Posted June 8, 2015 (edited) I want to use bindatcommand and manipulate it with switch, my players will be able to use numbers or characters like: @command 1 msg or @command broadcast msg My doubts are: before use switch(.@atcmd_parameters$[0]) will I need to use atoi to get number? can I use case "broadcast": on this?Thanks Edited June 8, 2015 by luan122 Quote Link to comment Share on other sites More sharing options...
Feilor Posted June 17, 2015 Group: Members Topic Count: 37 Topics Per Day: 0.01 Content Count: 135 Reputation: 17 Joined: 12/31/11 Last Seen: January 11 Author Share Posted June 17, 2015 (edited) I'm sorry I did the question by my cellphone, let me explain: I made a function to players get out of a pvp room, but they can use it to avoid others players... So I want to prevent it and know if is possible to cancel the event (actualy i'm using sleep2 to count down) and keeps player on the map. you can consider to use progressbar and not sleep2 Thanks to show me this option will be usefull Hey you're right, a progress bar would be nice. I already sent the script to him but I'll add that, it'll be nicer. Thanks I made alot of changes on the script hahaha I will show it to you soon, including the progressbar @Community I got answer for all my questions here they are: My doubts are: before use switch(.@atcmd_parameters$[0]) will I need to use atoi to get number? can I use case "broadcast": on this? I did this to solve the problem: OnInit: bindatcmd("tokens" ,"TokensFunc::OnTokens",0,99); end; OnTokens: @opcao = atoi(.@atcmd_parameters$[0]); @desc = atoi(.@atcmd_parameters$[1]); if(.@atcmd_parameters$[0] == "entrar") @opcao = 1; if(.@atcmd_parameters$[0] == "info") @opcao = 2; if(.@atcmd_parameters$[0] == "trocar") @opcao = 3; if(.@atcmd_parameters$[0] == "sair") @opcao = 4; switch(@opcao){ case 1: "script" end; FYI: dont use "case 0:" because the .@atcmd_parameters$[0] always come as 0 (idk why but it is okay) I'm sorry I did the question by my cellphone, let me explain:I made a function to players get out of a pvp room, but they can use it to avoid others players... So I want to prevent it and know if is possible to cancel the event (actualy i'm using sleep2 to count down) and keeps player on the map. @Kurofly helped me with this and teach me this: - script pvpexit -1,{ OnInit: .TimeToExit = 5; //amount of time before exiting (in seconds) bindatcmd "exit",strnpcinfo(0)+"::OnExit"; end; OnExit: dispbottom "You will exit the map after "+.TimeToExit+" seconds if you're not hurt."; @prev_hp = Hp; addtimer 100,strnpcinfo(0)+"::OnTimer"; end; OnTimer: @exittimer++; if (Hp < @prev_hp) { dispbottom "You've been hit! exitting cancel..." ; end; } @prev_hp = Hp; if (@exittimer >= .TimeToExit*10) { @exittimer = 0 ; warp getsavepoint(0),getsavepoint(1),getsavepoint(2) ; end; } addtimer 100,strnpcinfo(0)+"::OnTimer"; } Edited June 17, 2015 by luan122 Quote Link to comment Share on other sites More sharing options...
Kurofly Posted June 8, 2015 Group: Members Topic Count: 31 Topics Per Day: 0.01 Content Count: 283 Reputation: 31 Joined: 07/08/14 Last Seen: January 15, 2022 Share Posted June 8, 2015 Tell us exactly what you need to do, that's not really clear ^^ You can't use switch with strings because it's supposed to be used with numbers. Quote Link to comment Share on other sites More sharing options...
Feilor Posted June 8, 2015 Group: Members Topic Count: 37 Topics Per Day: 0.01 Content Count: 135 Reputation: 17 Joined: 12/31/11 Last Seen: January 11 Author Share Posted June 8, 2015 (edited) I'm thinking something like this:@token 0 or @token entrarthe code will be: OnInit: bindatcmd("tokens" ,"TokensFunc::OnTokens",0,99); end; OnTokens: switch(.@atcmd_parameters$[0]){ case 0: case "entrar": end; case 1: case "info" end; Edited June 8, 2015 by luan122 Quote Link to comment Share on other sites More sharing options...
Kurofly Posted June 8, 2015 Group: Members Topic Count: 31 Topics Per Day: 0.01 Content Count: 283 Reputation: 31 Joined: 07/08/14 Last Seen: January 15, 2022 Share Posted June 8, 2015 What is your script supposed to do? Quote Link to comment Share on other sites More sharing options...
Feilor Posted June 8, 2015 Group: Members Topic Count: 37 Topics Per Day: 0.01 Content Count: 135 Reputation: 17 Joined: 12/31/11 Last Seen: January 11 Author Share Posted June 8, 2015 It is a room that i don't want to use NPC, so the players will use @token (the system is called token) and the token will have a bunch of commands like: @tokens entrar (entrar = enter)@tokens info @tokens trocar (trocar = change) or the player can use: @tokens 1 @tokens 2 @tokens 3 I want to use the both way so I used switch to do that (since switch on languages can do the same i thought I could here I have a command called @vip src mod that does the same but I really don't want to make this a src (since the script is easier to change). I'm Brazilian sorry for the bad english ;( Quote Link to comment Share on other sites More sharing options...
Kurofly Posted June 8, 2015 Group: Members Topic Count: 31 Topics Per Day: 0.01 Content Count: 283 Reputation: 31 Joined: 07/08/14 Last Seen: January 15, 2022 Share Posted June 8, 2015 Guess you can't do that with switch, you'll have to put if statements. You could do something like this - script tokens -1,{ OnInit: bindatcmd "tokens",strnpcinfo(0)+"::OnTokens"; end; OnTokens: setarray .@list$ , "entrar","info","trocar"; for (.@i = 0 ; .@i < getarraysize(.@list$) ; .@i++) if (.@atcmd_parameters$[0] == .@list$[.@i]) .@num = .@i; switch(.@num) { case 1: warp "<location>",<x>,<y>; break; case 2: dispbottom "this is the info"; break; case 3: //don't know what you mean by change break; } if (!.@num) { dispbottom "unknown demand."; .@demands$ = .@list$; for (.@i = 1 ; .@i < getarraysize(.@list$) ; .@i++) .@demands$ = .@demands$ + " , "+.@list$[.@i]; dispbottom "Possible demands : "+.@demands$; } } using an array position to convert a string to a number Or you could use 1, 2, 3, etc.. as parameters and so use atoi Combinning the two would be too complicated for what you intend to do Quote Link to comment Share on other sites More sharing options...
Feilor Posted June 8, 2015 Group: Members Topic Count: 37 Topics Per Day: 0.01 Content Count: 135 Reputation: 17 Joined: 12/31/11 Last Seen: January 11 Author Share Posted June 8, 2015 I will try on my way... if not possible I will turn it a src based since the complexion to do with script, thanks! Quote Link to comment Share on other sites More sharing options...
Feilor Posted June 9, 2015 Group: Members Topic Count: 37 Topics Per Day: 0.01 Content Count: 135 Reputation: 17 Joined: 12/31/11 Last Seen: January 11 Author Share Posted June 9, 2015 I did with script But used if instead of setarray (easier and noob )and unfortunally I cant use 0 since @tokens keeps .@atcmd_parameters$[0] on 0 lol Can I know when someone get hit by script? Quote Link to comment Share on other sites More sharing options...
Kurofly Posted June 9, 2015 Group: Members Topic Count: 31 Topics Per Day: 0.01 Content Count: 283 Reputation: 31 Joined: 07/08/14 Last Seen: January 15, 2022 Share Posted June 9, 2015 When someone get hit by script? What do you mean by that? You know if you explain what you want to do in details I can surely do it for you. It's up to you. Quote Link to comment Share on other sites More sharing options...
Feilor Posted June 10, 2015 Group: Members Topic Count: 37 Topics Per Day: 0.01 Content Count: 135 Reputation: 17 Joined: 12/31/11 Last Seen: January 11 Author Share Posted June 10, 2015 (edited) I'm sorry I did the question by my cellphone, let me explain:I made a function to players get out of a pvp room, but they can use it to avoid others players... So I want to prevent it and know if is possible to cancel the event (actualy i'm using sleep2 to count down) and keeps player on the map. Edited June 15, 2015 by luan122 Quote Link to comment Share on other sites More sharing options...
Feilor Posted June 15, 2015 Group: Members Topic Count: 37 Topics Per Day: 0.01 Content Count: 135 Reputation: 17 Joined: 12/31/11 Last Seen: January 11 Author Share Posted June 15, 2015 someone? x.x Quote Link to comment Share on other sites More sharing options...
Kurofly Posted June 15, 2015 Group: Members Topic Count: 31 Topics Per Day: 0.01 Content Count: 283 Reputation: 31 Joined: 07/08/14 Last Seen: January 15, 2022 Share Posted June 15, 2015 Sorry totally forgot you meanwhile >< But dude I really don't get it, could you please send me a pm to clearly explain the concept to me? Tell me what is supposed to do your script? for whom? why? how? what features? Send me a pm so that I can ask some questions directly. Quote Link to comment Share on other sites More sharing options...
Emistry Posted June 17, 2015 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: 16 hours ago Share Posted June 17, 2015 I'm sorry I did the question by my cellphone, let me explain: I made a function to players get out of a pvp room, but they can use it to avoid others players... So I want to prevent it and know if is possible to cancel the event (actualy i'm using sleep2 to count down) and keeps player on the map. you can consider to use progressbar and not sleep2 1 Quote Link to comment Share on other sites More sharing options...
Kurofly Posted June 17, 2015 Group: Members Topic Count: 31 Topics Per Day: 0.01 Content Count: 283 Reputation: 31 Joined: 07/08/14 Last Seen: January 15, 2022 Share Posted June 17, 2015 Hey you're right, a progress bar would be nice. I already sent the script to him but I'll add that, it'll be nicer. Thanks 1 Quote Link to comment Share on other sites More sharing options...
Question
Feilor
I want to use bindatcommand and manipulate it with switch, my players will be able to use numbers or characters like:
@command 1 msg or @command broadcast msg
My doubts are:
before use switch(.@atcmd_parameters$[0]) will I need to use atoi to get number?
can I use case "broadcast": on this?

Edited by luan122Thanks
Link to comment
Share on other sites
14 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.