a better staffboots script ;)

-Staffboots-

Keys:

b = On/Off
+ = Faster
- = Slower

[CODE]if (playerenters) {
toweapons -Boots;
setimg wboots.png;

if (this.on == 1 && keypressed && keydown2(keycode(b),true)) {
this.on = 0;
setplayerprop #c,Staffboots: Off;
} else if (keypressed && keydown2(keycode(b),true)) {
this.on = 1;
this.speed = 1;
setplayerprop #c,Staffboots: On;
}

if (this.on == 1) {

if (keydown(0)) {playery=playery-this.speed}
if (keydown(1)) {playerx=playerx-this.speed}
if (keydown(2)) {playery=playery+this.speed}
if (keydown(3)) {playerx=playerx+this.speed}

if (keypressed && keydown2(keycode(+),true)) {
this.speed = this.speed+1;
setplayerprop #c, Speed: #v(this.speed);
}

if (keypressed && keydown2(keycode(-),true)) {
this.speed = this.speed-1;
setplayerprop #c, Speed: #v(this.speed);
}
}
timeout = 0.05;
}[/CODE]

made by Raman

1.) Remember the closing bracket on playerenters
2.) Try using vecx and vecy.

Oh, can you rescript it and post it here?
And i have a question…
why this script dont works ?

[CODE]// Server Time

if (playerenters) {
this.hours = 00;
this.minutes = 00;
this.seconds = 00;
}
if (created) {
this.seconds = this.seconds+1;
message #v(this.hours):#v(this.minutes):#v(this.seconds)
}
timeout=1;

if (this.seconds == 60) {
this.seconds = this.seconds-60;
this.minutes = this.minutes+1;
}

if (this.minutes == 60) {
this.minutes = this.minutes-60;
this.hours = this.hours+1;
}

if (this.hours == 24) {
this.hours = this.hours-24;
}[/CODE]

Don’t you ever fucking lie in forum titles again.

Forgot to place it in a loop

Yeah, I’m going to have to agree with Spooon. In no way is this better then most of the crap we already have on here. xd

Why don’t you just use modulo to set the variables in between 0 and 1 instead of using 8 lines for activation o_o

How can i place a loop?[COLOR=“Silver”]

---------- Post added at 08:31 PM ---------- Previous post was at 08:30 PM ----------

[/COLOR]And Spoon, why are you so mad?
Then don’t watch my scripts rage other peoples
i posted that script because there was no staffboots script whit ‘+’ and ‘-’

if (created) {
    timeout = 1;
}

if (timeout) {
    doStuff;
    timeout = 1;
}

Wow, I’ve never once thought of modulo to change an item; I’ve always just done item1 = !item1; for those types of things…

Ah hell, who took the screen name Staff Boots?

There is a staffboots code with + and -. xd

Also, why would you want set speeds on a bigmap? o_O

Another thing is you claim he is raging about your scripts.

You mean scripts you got probably from le DVD and know nothing about? Like that time for example.

Everyone will have the same time increment. But everyone will have different time whilst using it with the method that uses.

I learned that modulo trick from watching others scripts from downsider and tricxta :o and now I see a ton more use of it in Java, and c++
It’s surprising what a remainder can do xD

Here’s what you should have done:

// Server Time

if (playerenters) {
this.hours = 00;
this.minutes = 00;
this.seconds = 00;
timeout=1;
}
if(timeout){
this.seconds = this.seconds+1;
message #v(this.hours):#v(this.minutes):#v(this.seconds)

if (this.seconds == 60) {
this.seconds = this.seconds-60;
this.minutes = this.minutes+1;
}

if (this.minutes == 60) {
this.minutes = this.minutes-60;
this.hours = this.hours+1;
}

if (this.hours == 24) {
this.hours = this.hours-24;
}
timeout = 1;}

This is so every time a timeout runs out it checks the variables.
Personnally I took so much time figuring that out back in 2001… I used to put a lot of sleeps and repeat my code X_X.

Modulo and divisions would be worth it in here since you’d be using only one var and have a much shorter script.
(notice how I used “+=”)

if (playerenters) {
this.seconds = 00;
timeout=1;
}
if(timeout){
this.seconds += 1;
message #v(int(this.seconds/3600)%24):#v(int(this.seconds/60)%60):#v(this.seconds%60)
timeout = 1;}

However this would reset every time you reconnect, since you are using a this. variable… and would also reset every time the player enters the level, which is probably unwanted.
Therefore, remember that in gscript you do not have to declare your variables before using them, and that client. variables (which are sadly always stored as strings) are permanent, like flags.
You should also use a npcw so the time always increments, and not only in the current level, but there’s one problem, the timeout will stop looping once you reconnect, so you will need to init the timeout on playerenters(which is usually what happens most often after a reconnection). But you don’t always want the timeout to start back to 1 on playerenters, so we’ll use a this. var to make sure this doesn’t happen. We also don’t want the level’s npc to increment client.seconds since it’s the npcw’s job, so to avoid client.seconds incrementing twice, we make sure the npc is a weapon.
So I’d personally write it this way:

if(created){
toweapons -servertime;
this.init=1;
timeout = 1;
}
if(playerenters&&this.init==0&&isweapon){ //since this.init has not been declared, it's equal to zero
this.init = 1;
timeout = 1;
}
if(timeout&&isweapon){
setstring client.seconds,#v(strtofloat(#I(client.seconds,0))+1);
message #v(int(strtofloat(#I(client.seconds,0))/3600)%24):#v(int(strtofloat(#I(client.seconds,0))/60)%60):#v(strtofloat(#I(client.seconds,0))%60)
timeout = 1;}

The downside is that it calculates play time and not server time, anyways, this should help you script better.

Good luck, and don’t hesitate if you have further questions :)[COLOR=“Silver”]

---------- Post added at 10:37 PM ---------- Previous post was at 10:33 PM ----------

[/COLOR]Twiggy, is that Santa in your avatar?

Nah, it’s a plant race from a game called Starbound. :stuck_out_tongue:

Why don’t you just use timevar when you make time?

Because I forgot it existed and because I wanted to use his script as a base to teach him stuff…anyway time keeping is pretty useless imo.

I feel dizzy.

http://forums.graal.in/forums/showthread.php?2012-Useful-Formulas-and-Other-Things&p=94512&viewfull=1#post94512