Jump to content
  • 0

Menu and survival


cder

Question


  • Group:  Members
  • Topic Count:  36
  • Topics Per Day:  0.02
  • Content Count:  96
  • Reputation:   0
  • Joined:  08/06/18
  • Last Seen:  

Hello guys, I need help with a script, would be a survival system, to open more customization in ragnarok, I would like to remind you that I am Brazilian, so the script exists sets in Portuguese, but bullshit like "hunger, thirst, sleep , weapon and armor durability "
Spoiler

prontera,153,173,5    script    sobrevivencia    85,{
.@fome$ = "[Fome]";
.@sede$ = "[Sede]";
.@sono$ = "[Sono]";
.@dubarma$ = "[DubArma]";
.@dubarmadura$ = "[DubArmadura]";
getcharid(0);
        
        if(getcharid(0)){
        OnPCLoginEvent:
        addtimer 1000, strnpcinfo(3) + "::OnSurvival";
        end;
        OnSurvival:
        setd ".@fome$", "80";
        setd ".@sede$", "80";
        setd ".@sono$", "80";
        deltimer strnpcinfo(3) + "::OnSurvival";
        addtimer 1000, strnpcinfo(3) + "::OnPenality1";
        addtimer 1000, strnpcinfo(3) + "::OnPenality2";
        end;
        OnPenality1:
            deltimer strnpcinfo(3) + "::OnPenality1";
                if (.@fome > 0 && .@sede > 0){
                .@fome = -1;
                .@sede = -1;
                addtimer 30000, strnpcinfo(3) + "::OnPenality1";
                }
                else 
                    warp "sec_pri",50,76;
                    end;
        OnPenality2:
            deltimer strnpcinfo(3) + "::OnPenality2";
                if (.@sono > 0){
                .@sono = -1;
                addtimer 30000, strnpcinfo(3) + "::OnPenality2";
                }
                else
                    warp "sec_pri",50,76;
                    end;
                            if (.@fome > 100 && .@sede > 100 && .@sono > 100 && .@dubarma > 100 && .@dubarmadura > 100){
                            setd ".@fome$", "100";
                            setd ".@sede$", "100";
                            setd ".@sono$", "100";
                            setd ".@dubarma$", "100";
                            setd ".@dubarmadura$", "100";
                            end;
        }
    }
}    

this is a npc I used to create a system, if hungry, thirsty, sleep is at 0 he would take the player to prison, the problem is that he even takes my character to prison, but I don't know how I can make the player start with 80's hunger, thirst, sleep, and he ends up being taken to prison after the programming detects that he is at 0, and even in the menu npc I created when using the @menu all status command is at 0. .. below is the menu script
Spoiler

prontera,155,160,5    script    menu    85,{
.@nome$ = "[Menu]";
getvariableofnpc(.@fome,"sobrevivencia");
getvariableofnpc(.@sede,"sobrevivencia");
getvariableofnpc(.@sono,"sobrevivencia");
getvariableofnpc(.@dubarma,"sobrevivencia");
getvariableofnpc(.@dubarmadura,"sobrevivencia");

menu1:
mes .@nome$;
mes "[Fome]:"+.@fome;
mes "[Sede]:"+.@sede;
mes "[Sono]:"+.@sono;
mes "[DubArma]:"+.@dubarma;
mes "[DubArmor]:"+.@dubarmadura;
close;
end;

    
    atcommand "@menu";
    charcommand "strcharinfo(0)";
    OnInit:
        bindatcmd "@menu",strnpcinfo(3) + "::OnAtcommand";
        end;
    OnAtcommand:
        menu "Menu",menu1;
        close;
        end;
}

Can anyone help me assign 80 hunger, thirst, sleep to the player creating the character?

 

Edited by cder
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   703
  • Joined:  12/21/14
  • Last Seen:  

the script is a Disaster

 

what the point of the script ? what the point of the 

hunger, thirst, sleep

how the player gain or loss them ?

 

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  36
  • Topics Per Day:  0.02
  • Content Count:  96
  • Reputation:   0
  • Joined:  08/06/18
  • Last Seen:  

10 hours ago, sader1992 said:

the script is a Disaster

 

what the point of the script ? what the point of the 


hunger, thirst, sleep

how the player gain or loss them ?

 

 

@sader1992

if hungry, thirsty, sleep reaches 0 the character will be deleted, but I used jail as an example, after the script is still under development, how it gets earned, sleep wins with npc bed, durability wins with npc repairer, and hunger and thirst wins by putting set in the script of itemdb, this my script is much more complex, but to do the advanced is necessary the basic ...

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  26
  • Reputation:   1
  • Joined:  06/25/16
  • Last Seen:  

Oooookkkk... (man this is gonna hurt my mind a lot, better you appreciate it)

Let´s not call it a disaster, could be a great idea but... you will need to improve your scripting skills a lot if you want to develop something that complicate.

Let´s go little by little...

prontera,153,173,5    script    sobrevivencia    85,{
.@fome$ = "[Fome]";
.@sede$ = "[Sede]";
.@sono$ = "[Sono]";
.@dubarma$ = "[DubArma]";
.@dubarmadura$ = "[DubArmadura]";
getcharid(0);

You declare 5 scope variables with some names. Ok:

".@"     - A scope variable.
           They are unique to the instance and scope. Each instance has its
           own scope that ends when the script ends. Calling a function with
           callsub/callfunc starts a new scope, returning from the function
           ends it. When a scope ends, its variables are converted to values
           ('return .@var;' returns a value, not a reference).

"scope that ends when the script ends" that means this kind of variables will stop existing as soon the script reach an end; or close; statement. (Maybe not what you want since this variables seems to be like constants).

Then you call getcharid for no reason... I mean, you are not saving the result to any variable or using it for nothing. You can take that out trust me.

 

SECOND PART.

if(getcharid(0)){
        OnPCLoginEvent:
        addtimer 1000, strnpcinfo(3) + "::OnSurvival";
        end;
        OnSurvival:
        setd ".@fome$", "80";
        setd ".@sede$", "80";
        setd ".@sono$", "80";
        deltimer strnpcinfo(3) + "::OnSurvival";
        addtimer 1000, strnpcinfo(3) + "::OnPenality1";
        addtimer 1000, strnpcinfo(3) + "::OnPenality2";
        end;
        OnPenality1:
            deltimer strnpcinfo(3) + "::OnPenality1";
                if (.@fome > 0 && .@sede > 0){
                    .@fome = -1;
                    .@sede = -1;
                    addtimer 30000, strnpcinfo(3) + "::OnPenality1";
                }
                else 
                warp "sec_pri",50,76;
                end;
        OnPenality2:
            deltimer strnpcinfo(3) + "::OnPenality2";
                if (.@sono > 0){
                .@sono = -1;
                addtimer 30000, strnpcinfo(3) + "::OnPenality2";
                }
                else
                    warp "sec_pri",50,76;
                    end;
                            if (.@fome > 100 && .@sede > 100 && .@sono > 100 && .@dubarma > 100 && .@dubarmadura > 100){
                            setd ".@fome$", "100";
                            setd ".@sede$", "100";
                            setd ".@sono$", "100";
                            setd ".@dubarma$", "100";
                            setd ".@dubarmadura$", "100";
                            end;
        }
    }

 

Ok... ok ok.. ok. Why that if?? It´s like if youy put something like... if(1) GO AHEAD. So that if.. you can take it out and do it without that.

I´m not gonna talk about timers, I hate them.

Then my favorite part. You declare text variables to store numbers... as text. Oh man, I hope you don´t wanna do some number comparisons later... wait.. you don´t because... oh...

Yo you put some texts as "80" and then... put some timers to substract other variables not previously declared...

Ok... ok, I tried to fix it a little, have it a look and try to understand why I did the changes. If I do all the work you won´t improve:

prontera,153,173,5    script    sobrevivencia    85,{

OnPCLoginEvent:
addtimer 1000, strnpcinfo(3) + "::OnSurvival";
end;

OnSurvival:
set fome, 80;
set sede, 80;
set sono, 80;
deltimer strnpcinfo(3) + "::OnSurvival";
addtimer 1000, strnpcinfo(3) + "::OnPenality1";
addtimer 1000, strnpcinfo(3) + "::OnPenality2";
end;

OnPenality1:
    deltimer strnpcinfo(3) + "::OnPenality1";
        if (fome > 0 && sede > 0){
            fome = -1;
            sede = -1;
            addtimer 30000, strnpcinfo(3) + "::OnPenality1";
            if (fome > 100){set fome, 100;}
            if (sede > 100){set sede, 100;}
            if (dubarma > 100){set dubarma, 100;}
            if (dubarmadura > 100){set dubarmadura, 100;}
            end;
        }else{
            warp "sec_pri",50,76;
            end;
        }
        
OnPenality2:
    deltimer strnpcinfo(3) + "::OnPenality2";
        if (sono > 0){
            sono = -1;
            addtimer 30000, strnpcinfo(3) + "::OnPenality2";
            if (sono > 100){set sono, 100;}
            if (dubarma > 100){set dubarma, 100;}
            if (dubarmadura > 100){set dubarmadura, 100;}
            end;
        }else{
            warp "sec_pri",50,76;
            end;
        }
    
    OnInit:
    $fome$ = "[Fome]";
    $sede$ = "[Sede]";
    $sono$ = "[Sono]";
    $dubarma$ = "[DubArma]";
    $dubarmadura$ = "[DubArmadura]";
    
}

BUT, i didn´t test it so I´m not sure about this. I didn´t look all the script, just cleaned the biggest parts.

Keep the work!

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...