Announcement

Collapse
No announcement yet.

Using Custom Pawn

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Using Custom Pawn

    I'm having problems using my custom xpawn. Getting it ingame isn't the problem its changing the variables I created on it. For example, i created a experience variable on the xpawn and tried to make a monster give experience when you kill it.

    When i try to compile the code, it gives me an error that it can't find the variable in class pawn

    #2
    Show me the code that gives the experience to the player. You are probably calling the player, literally, "pawn".

    Maybe in the manner of: local Pawn aCharacter;

    So it looks at your Player's literal "PAWN" class. The variable doesn't exist in pawn, it exists in your extension of xpawn.

    ( pawn -> xpawn -> yourpawn )

    So say 'your pawn' that extends xpawn is called "MyPawn".

    You need to have the experience addition code reflect MyPawn not pawn. If you do this via a local variable, it's:

    local MyPawn aCharacter;

    Of course, you can replace 'aCharacter' with whatever you want the variable in that function to be named.

    It's quite specific in the class it ends up looking for the variable in. From what you said your error is, I think what I've told you is dead on. I'm a little new myself, but I've been down that street, bro.

    If you need any further assistance, post your EXP giving code and I'll help ya out. :noob:

    Comment


      #3
      May be like this :

      local Pawn p;

      if (MyPawn(p) != none) // to be sure that 'p' is a 'MyPawn'
      MyPawn(p).Experience += 1;

      Comment


        #4
        Code:
        local MyPawn p;
        
        if (p != none)
        p.Experience += 1;
        ...should work fine. I have a similar dealing that does it like this.

        Comment

        Working...
        X