Jump to content
MakeWebGames

Points Visible on UsePoints Mod (Understanding functions better)


AinzOoalGown

Recommended Posts

Hi All,

I'm still learning so I have another question (more will come I'm sure lol)

So I am using the "UsePoints" mod that is part of GL V2 Premium. I have found that a players points is not shown anywhere. I am able to add them to main template header with no issues, but I also wanted to add them to the users profile and in the Use Points section so a player can see the points they currently have.

When I try to use {points} in "usePoints.tpl.php" it does not display anything, so though I would have to invoke it. So I edited "usePoints.inc.php" and added "$USpoints = $this->user->info->US_points;" (as "points" was already being used I think, so went with "USpoints") and place it in other functions in usePoints.inc.php to no joy.

I edited "usePoints.tpl.php" like this:

            <div class="panel panel-default">
                <div class="panel-heading">{_setting "pointsName"} Store</div>
                <div class="panel-body">
                   {_setting "pointsName"} {USpoints}
                    {#each items}
                        <div class="crime-holder">
                            <form action="?page=usePoints&action=buy" method="post">
                                <p>
                                    <span class="action">
                                        {name} 
                                    </span> 
                                    <span class="cooldown">
                                        {number_format cost} {_setting "pointsName"}
                                    </span> 
                                    <span class="cooldown ">
                                        <input type="number" name="qty" class="form-control" placeholder="Qty." {#if max}max="{max}"{/if} />
                                    </span> 
                                    <button name="item" value="{id}" class="btn btn-default" href="?page=crimes&action=commit&crime={id}">
                                            Buy
                                    </button>
                                </p>
                            </form>
                        </div>
                    {/each}
                </div>
            </div>

Adding this bit:

{_setting "pointsName"} {USpoints}

I then tried to create a new function just to have "$USpoints = $this->user->info->US_points;" in it:

        public function pullUserData() {

            $page->addToTemplate('USpoints', $this->info->US_points);     

        }

Not sure what I am doing wrong. However I am still unable to pull the players points into the form. The points name shows no problem.

If anyone could point me in the right direction that would be great. Still learning how the system pulls data around.

Thanks 🙂

Link to comment
Share on other sites

9 hours ago, Sim said:

Look into the hooks. You can add text,links to profile


$this->user->info->US_points

forgot user

So I tried adding a line to the usePoints.hook.php:

    new hook("pointsMenu", function () {
        $pointsName = _setting("pointsName");
        $USpoints = $this->user->info->US_points;
        return array(
            "url" => "?page=usePoints", 
            "text" => $pointsName . ' Shop'
        );
    });

I added:

$USpoints = $this->user->info->US_points;

But didnt seem to do anything. I checked the hooks info on github and tried to add a new hook to usePoints.hook.php from userInformation:

new Hook("userInformation", function ($user) {
  global $page;
  $page->addToTemplate('USpoints', $this->info->US_points);
});

But this didnt seem to do anything either. Still cant show points.

Link to comment
Share on other sites

Inside your modules you will use $this->user->info->FIELD_NAME

 

Inside hooks file, your need to makw $user global

 

new Hook("userInformation", function ($user) {
  global $page, $user;
  $page->addToTemplate('USpoints', $user->info->US_points);
});

user information stored in $user, not $this like u dis.

Link to comment
Share on other sites

5 minutes ago, Sim said:

Inside your modules you will use $this->user->info->FIELD_NAME

 

Inside hooks file, your need to makw $user global

 


new Hook("userInformation", function ($user) {
  global $page, $user;
  $page->addToTemplate('USpoints', $user->info->US_points);
});

user information stored in $user, not $this like u dis.

Ah right I understand that bit now for hooks.

I have added the new hook, and added $USpoints = $this->user->info->US_points; to userPoints.inc.php, but it still is not displaying users points on the page.

Link to comment
Share on other sites

7 minutes ago, PHPStudent12 said:

So I was trying to do this myself and managed to add it in my template (Mccodes theme), which I gather you've already figured out. To add to profile, just add this snippet of code in the array section

"points" => $this->user->info->US_points,


"points" => $this->user->info->US_points,

 

Hi thanks. I have it working in profile, it actually in the "Points Shop" I'm trying to display it, so a player can see how many points they have to spend.

At the top of the page I have added the text but cant get the actual points to display next to it.

ps.PNG

AH! Found it!!! 🙂

The array is at the very bottom of the file!. So just added "USpoints" => $this->user->info->US_points and it works now 😄

        public function constructModule() {
            $items = $this->getItems();
            $this->html .= $this->page->buildElement("shop", array(
                "items" => $items,
                "USpoints" => $this->user->info->US_points
            ));
        }

 

  • Confused 1
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
Reply to this topic...

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