Author Topic: RPG mod help  (Read 1432 times)

So im making a RPG game so i need Levels and stuff but i dont know how to make it to where when a bot is killed it gives EXP, i know i have to make a Event for that but how would i do it? this is the script i have so far:
Code: [Select]
package EXP

{

        function gameConnection::onDeath(%Client, %KillerPlayer, %Killer, %damageType, %a)

        {

                Parent::onDeath(%Client, %KillerPlayer, %Killer, %damageType, %a);       

                %Killer.Xp += 50;

        }

        function GameConnection::OnClientEnterGame(%Client)

         {

            %Client.Schedule(1500,0, SendXpMessage);

            Parent::OnClientEnterGame(%Client);

        }

       

        function SendXpMessage(%Client)

        {

                if(%Client.Xp > %Client.Level*100)

                {

                        %Client.Xp -= %Client.Level*100;

                        %Client.Level++;

                        SendXpMessage(%Client);

                        Return;

                }

                BottomPrint(%Client,"Level:" @ %Client.Level @ "XP:" @ %Client.Xp,7);

                %Client.Schedule(2000,0, SendXpMessage);

        }

        function AddXp(%Client,%Amt)

        {

            %Client.Xp += %Amt;

           

        }

};

ActivatePackage(EXP);

what is with those spaces


Quite the opposite effect, actually

well it just seems easier to me

Quite the opposite effect, actually

To you it is, to some it is easier.

spawn a bot, look at it, type /getid
it should tell you what the bot is, something like AIplayer, which you can then do AIplayer::ondeath

To you it is, to some it is easier.
I suppose
I personally like to be able to read code without scrolling down every few seconds

Wouldn't every time you load the save the id would change?

he's not saying you need the id, he's saying that you need the object type to package object::onDeath
so like he was saying, /getid to get the object type rather than the object id

Ohh I see, got it thanks

Ok for some reason this doesn't work please help me
Code: [Select]
package EXP
{
        function gameConnection::onDeath(%Client, %KillerPlayer, %Killer, %damageType, %a)
        {
                Parent::onDeath(%Client, %KillerPlayer, %Killer, %damageType, %a);       
                %Killer.Xp += 50;
        }
        function GameConnection::OnClientEnterGame(%Client)
         {
            %Client.Schedule(1500,0, SendXpMessage);
            Parent::OnClientEnterGame(%Client);
        }
       
        function SendXpMessage(%Client)
        {
                if(%Client.Xp > %Client.Level*100)
                {
                        %Client.Xp -= %Client.Level*100;
                        %Client.Level++;
                        SendXpMessage(%Client);
                        return;
                }
                BottomPrint(%Client,"Level:" @ %Client.Level @ "XP:" @ %Client.Xp,7);
                %Client.Schedule(2000,0, SendXpMessage);
        }

        function AIPlayer::onDeath(%Client)
        {
            %Client.Xp += getRandom( 1, 10 );
        }
};
ActivatePackage(EXP);

i think you're trying to add XP to the dead bot
killer client is 3rd? it seems that way from your first function

yea i think that would be why the print doesn't show up
what if i just remove the game connections? and just have the AIPlayer::ondeath would it work?
« Last Edit: July 05, 2012, 07:31:42 AM by bloxmaster »

yea i think that would be why the print doesn't show up
what if i just remove the game connections? and just have the AIPlayer::ondeath would it work?
A player is not an AIPlayer. Do not remove the gameConnection part.