Author Topic: Lvl Coresponding to Exp?  (Read 1382 times)

K well I made a script that partially work's but when you have exp and type /checklvl it show's the lvl as "Lvl:" with no number even with 50+ or 0+

Code: [Select]
//ExpTest

function serverCmdCheckExp(%client)
    {
       messageClient(%client,'','\c5Exp: %1',%client.Exp);
}

function serverCmdCheckLvl(%client)
    {
       messageClient(%client,'','\c5Lvl: %1',%client.Lvl);
}

function Rpgset(%client,%Exp)
{
If(%Client.exp >= 0);
%Client.Lvl = 1;

If(%Client.exp >= 50);
%Client.Lvl = 2;
}

function serverCmdGrantExp(%client,%victim,%amount)
{
   if(%amount<=0||%Amount>%client.Exp)
    %victim = findClientByBL_ID(%victim);
    if(!isobject(%victim)){return;}
    %victim.Exp+=%amount;
     messageClient(%client,'','Gave 2% %1',%client.Exp,%amount);
}

This is called debugging and it's important that you can do this so you don't have to make a new topic every time you get a syntax error.

The problem is the message "\c5Lvl: %1" (where %1 is the client's level) prints "Lvl: ". In other words, it's saying the client's level is blank, right? That means you never assigned a value to the client's level.

Now, you go into your code and figure out why the client's level has no value. The function that's supposed to give a value to the client's level is the Rpgset(), where you say:
Code: [Select]
If(%Client.exp >= 0);
%Client.Lvl = 1;

If(%Client.exp >= 50);
%Client.Lvl = 2;

That's not even torque script. You have extra semi-colons in there and keywords shouldn't be capitalized.


Eonz, the console tells you where you have errors in your code.
« Last Edit: June 13, 2008, 03:37:00 PM by exidyne »

Where does it actually call rpgset()?

It didn't give me any syntax's  it just appeared blank...

Capitalization makes no diffrence.
The prolem is the ;s after the ifs

I would go with a more general equasion, where you don't have to add an if for each level.

And you need to add a call to rpgset in grantexp
And some problems in the message.

Code: [Select]
//ExpTest

function serverCmdCheckExp(%client)
    {
       messageClient(%client,'','\c5Exp: %1',%client.Exp);
}

function serverCmdCheckLvl(%client)
    {
       messageClient(%client,'','\c5Lvl: %1',%client.Lvl);
}

function Rpgset(%client)
{
If(%Client.exp >= 0)
%Client.Lvl = 1;

If(%Client.exp >= 50)
%Client.Lvl = 2;
}

function serverCmdGrantExp(%client,%victim,%amount)
{
   if(%amount<=0||%Amount>%client.Exp)
    %victim = findClientByBL_ID(%victim);
    if(!isobject(%victim)){return;}
    %victim.Exp+=%amount;
     messageClient(%client,'','Gave 2% %1',%victim.name,%amount);
    Rpgset(%victim);
}


Also, Runeth, instead of reseting the rpg to gain levels... You could make it every time you gain exp, your amount gets checked. If its high enough you get a level.

Also, Runeth, instead of reseting the rpg to gain levels... You could make it every time you gain exp, your amount gets checked. If its high enough you get a level.

Thats what it does...