Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-03-2008, 01:47 PM
Chompy Chompy is offline
»\(║_o)/»
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Basic leveling system

Graal Script Code:
function onActionServerside() {
  switch(
params[0]) {
    case 
"levelup":
      
// Add leveling up code here
    
break;
    case 
"report":
      
makevar(params[4]) = params[2]; // Resets level to old level
      
sendtorc("[LEVELING ABUSE]: "params[1] @" leveled from "params[2] @" to "params[3] @"!");
    break;
  }
}
//#CLIENTSIDE
function onCreated() {
  
/* Change this to your level variable being used,
     for example: "clientr.level" */
  
this.levelvar "clientr.level";
  
  
/* Change this to your exp variables being used,
     for example: {"clientr.exp", "clientr.maxexp"} */
  
this.exp = {"clientr.exp""clientr.maxexp"};
  
  
  
// Don't change anything below, unless you want to change
  // the timeout or edit the anti-abuse yourself :)
  
this.leveling false;
  
this.lvl makevar(this.levelvar);
  
setTimer(1);
}
function 
onTimeout() {
  if (!
this.leveling) {
    if (
makevar(this.exp[0]) >= makevar(this.exp[1])) {
      
this.leveling true;
      
triggerserver("gui"this.name"levelup"player.account);
    }
  }else if (
this.lvl makevar(this.levelvar)) {
    if ((
makevar(this.levelvar)-this.lvl) == 1) {
      
this.leveling false;
      
this.lvl makevar(this.levelvar);
      
    }else if ((
makevar(this.levelvar)-this.lvl) > 1) {
      
player.triggerserver("gui"this.name"report"player.accountthis.lvlmakevar(this.levelvar), this.levelvar);
      
sleep(0.5);
      
serverwarp("login2");
    }
  }
  
setTimer(1);

Well, a basic leveling system with a little anti-abuse system. Basicly, with this system you can't level up 2 levels at once. If your level changes by 2 or above from your old level it will register by echo'ing at rc that the person got his levels up by 2 or above, reset his level and then serverwarp him to login2.

It might look kinda messy, but that's because I added support so you could modify it by only changing two vars listed in the onCreated() event (this.levelvar and this.exp).

If you want to add more logging, simple edit the switch case labeled reset with code you want in. I have not added any leveling up code, that you have to make yourself, so it will fit your server's leveling up plans etc.

Any questions, suggestions to improve it etc are welcome.

And.. uhm.. enjoy?
__________________
Reply With Quote
  #2  
Old 02-03-2008, 02:44 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
JEEZ MAN. Calm down! lol

You're posting like two things in a day in the code gallery.

Great script as always!
__________________
Reply With Quote
  #3  
Old 02-03-2008, 02:47 PM
Chompy Chompy is offline
»\(║_o)/»
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by cbkbud View Post
JEEZ MAN. Calm down! lol

You're posting like two things in a day in the code gallery.

Great script as always!
Thanks Chris Yeah, I feel in a mood to release stuff :P

Planning on releasing some of my old stuff, maybe some old mudlib I've done :o

Anyways, thanks again
__________________
Reply With Quote
  #4  
Old 07-08-2008, 04:05 AM
kodster200 kodster200 is offline
One Globals Love To Hate
kodster200's Avatar
Join Date: Aug 2006
Posts: 17
kodster200 is an unknown quantity at this point
k newb question i know but

1. can i possibly use this on my friends server?

2. does it just go into like a weapon type script oooor is it much more advanced xD i r nub
Reply With Quote
  #5  
Old 07-08-2008, 12:16 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Sorry Chompy, but I don't like it. Any half decent leveling system would be controlled entirely on serverside, and definitely not in a timeout. All checks should be in a level up function, that ONLY an add exp function would trigger (ever).


Quote:
Originally Posted by kodster200 View Post
k newb question i know but

1. can i possibly use this on my friends server?

2. does it just go into like a weapon type script oooor is it much more advanced xD i r nub
1. You may use all codes in the Code Gallery anywhere you want to.

2. Yes, in a Weapon NPC.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #6  
Old 08-02-2008, 05:30 PM
_Z3phyr_ _Z3phyr_ is offline
Banned
Join Date: Sep 2003
Location: Louisiane
Posts: 390
_Z3phyr_ is an unknown quantity at this point
basic? i'll show you a basic levelup script:

Graal Script Code:
if (exp>needed) {
  
levelup();
}
function 
levelup() {
  
level++;
  
//levelup code here

Reply With Quote
  #7  
Old 08-04-2008, 09:17 PM
Chompy Chompy is offline
»\(║_o)/»
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Hmm, just noticed that this thread was bumped..

Ziro, the code is old though ;o I'll see if I get time to update the code though..

Edit: Made this up fast

Graal Script Code:
public function onCheckExp(obj) {
  if (
obj.clientr.exp >= obj.clientr.maxexp) {
    
onLevelUp();
  }
}

function 
onLevelUp() {
  
// leveling up code here

Basically where you add exp to the player, you would trigger the function onCheckExp(obj), obj being the object of the player.

For example if you put this script in a wnpc named LevelingSystem, you would do this where you add exp:

Graal Script Code:
// 'temp.pl' being the player object

LevelingSystem.trigger("CheckExp"temp.pl);

// or

LevelingSystem.onCheckExp(temp.pl); 
Could probably improve it later, just don't have the time right now
__________________

Last edited by Chompy; 08-04-2008 at 09:29 PM..
Reply With Quote
  #8  
Old 08-04-2008, 11:11 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
I'd do it with this structure:

Graal Script Code:
function AddMoreExp()
{
  
currentexperience ++;
  if (
currentexperience >= maxexperience) {
    
LevelUp();
  }
}

function 
LevelUp()
{
  if (
currentexperience maxexperience) {
    echo(
"AHMAGAWD CORRUPT STAFF SLASH HACKER ALERT!!!");
    return;
  }

  
currentexperience -= maxexperience;

  
// Level up!

Rough draft, but you get the idea.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #9  
Old 08-04-2008, 11:21 PM
Chompy Chompy is offline
»\(║_o)/»
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Hmm, that code wouldn't do well though, as it would return all the time :O

But, yeah, I would of made the levelup() function public or an addexp() function.. but yeah, get the 'draft' ;p
__________________
Reply With Quote
  #10  
Old 08-04-2008, 11:26 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by Chompy View Post
Hmm, that code wouldn't do well though, as it would return all the time :O
I fixed that while you were typing, forgot to change >= to < after I copied it from AddMoreExp()
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #11  
Old 08-04-2008, 11:29 PM
Chompy Chompy is offline
»\(║_o)/»
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by xXziroXx View Post
I fixed that while you were typing, forgot to change >= to < after I copied it from AddMoreExp()
:] Yeah, I was wondering if you did it fast :o
__________________
Reply With Quote
  #12  
Old 02-26-2009, 08:13 PM
xfazex xfazex is offline
Registered User
Join Date: Feb 2009
Location: Eastern Shore, Maryland USA
Posts: 81
xfazex is an unknown quantity at this point
Send a message via AIM to xfazex Send a message via MSN to xfazex Send a message via Yahoo to xfazex Send a message via Skype™ to xfazex
Does this just go as a server wnpc and add it to myself for testing? Did that and didn't see anything at all.

I r noob.
Reply With Quote
  #13  
Old 02-28-2009, 02:09 PM
Chompy Chompy is offline
»\(║_o)/»
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by xfazex View Post
Does this just go as a server wnpc and add it to myself for testing? Did that and didn't see anything at all.

I r noob.
Depends on which code you used.

The latest ones, (the ones without a timeout) are more of an 'utility' code, which you use after adding experience to the player.

The script is quite old (based on when I made it), and now a days I would of done it another way

PS: This script is dependent that you script the leveling up formula and the actions the script will do when the player actually levels up
__________________
Reply With Quote
  #14  
Old 02-28-2009, 05:34 PM
xfazex xfazex is offline
Registered User
Join Date: Feb 2009
Location: Eastern Shore, Maryland USA
Posts: 81
xfazex is an unknown quantity at this point
Send a message via AIM to xfazex Send a message via MSN to xfazex Send a message via Yahoo to xfazex Send a message via Skype™ to xfazex
Only if I was better at GS2...
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 06:33 AM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.