AinzOoalGown Posted December 30, 2020 Share Posted December 30, 2020 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 🙂 Quote Link to comment Share on other sites More sharing options...
Sim Posted December 30, 2020 Share Posted December 30, 2020 Look into the hooks. You can add text,links to profile $this->user->info->US_points forgot user Quote Link to comment Share on other sites More sharing options...
AinzOoalGown Posted December 30, 2020 Author Share Posted December 30, 2020 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. Quote Link to comment Share on other sites More sharing options...
Sim Posted December 30, 2020 Share Posted December 30, 2020 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. Quote Link to comment Share on other sites More sharing options...
AinzOoalGown Posted December 30, 2020 Author Share Posted December 30, 2020 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. Quote Link to comment Share on other sites More sharing options...
Sim Posted December 30, 2020 Share Posted December 30, 2020 https://github.com/ChristopherDay/Gangster-Legends-V2/wiki/Hooks I forget hook to add text to profile @Dayo ? Quote Link to comment Share on other sites More sharing options...
AinzOoalGown Posted December 30, 2020 Author Share Posted December 30, 2020 @Dayo Do you have an idea on how this is accomplished as I'm still stuck and cant figure it out 😛 Thanks Quote Link to comment Share on other sites More sharing options...
Sim Posted December 31, 2020 Share Posted December 31, 2020 Last hook https://github.com/ChristopherDay/Gangster-Legends-V2/wiki/Hooks.modules Quote Link to comment Share on other sites More sharing options...
PHPStudent12 Posted December 31, 2020 Share Posted December 31, 2020 (edited) 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, Edited December 31, 2020 by PHPStudent12 1 Quote Link to comment Share on other sites More sharing options...
AinzOoalGown Posted December 31, 2020 Author Share Posted December 31, 2020 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. 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 )); } 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.