Jump to content
MakeWebGames

Small gang update to remove Underboss when you are boss plus a few extras


Uridium

Recommended Posts

it seems the underboss can remove themselves but the boss cannot remove them other than kicking them..

 

open up gangs.inc.php

and add this >>

/* start underboss removal */
		
		        public function method_removeUnderboss() {
            if (!$this->user->info->US_gang) return;
            $this->construct = false;
            $gang = new Gang($this->user->info->US_gang);
            
            if ($this->user->id != $gang->gang["boss"]) {
                $this->error("You dont have permission to do this!");
                return $this->method_home();
            }

            $id = $this->methodData->user;

            $newUB = new User($id);

            $oldUB = new User($gang->gang["underboss"]);

            if ($newUB->id && $newUB->info->US_gang != $this->user->info->US_gang) {
                $this->error("This user is not part of this gang!");
                return $this->method_home();
            }

            $update = $this->db->prepare("UPDATE gangs SET G_underboss = 0 WHERE G_id = :id");
            $update->bindParam(":id", $gang->id);
            $update->execute();

            if ($oldUB->id != 0) {
                $oldUB->newNotification("You have been demoted from underboss of " . $gang->gang["name"]);
            }

            $this->error("Underboss Removal updated", "success");
            if ($newUB->id != 0) {
                $gang->log("was removed as the underboss", $oldUB);
            }
            $this->method_home();

        }
		
		/* end removal */

after public function method_setUnderboss() section

 

now open gangs.tpl.php and add 

{#if isBoss}
                                        <p>
                                            <button name="action" value="removeUnderboss" class="btn btn-block btn-default">
                                                Remove Underboss
                                            </button>
                                        </p>
                                    {/if}

after your setUnderboss class

and your done

 

if you notice on your gangs home page it says Gand Information you can change that word Gang to your gang name..

look for public $gangHome ='

and from there just change {_settings "gangName"} to become {name} and your given gang name will appear

 

dont alter the one for public $gangs = ' as that one is for the viewing of listed gangs

 

 

 

 

 

Link to comment
Share on other sites

 

very nice did have a look at making something similar havent been on default GL in a while but here you go this should do the trick.

first find the following around line 267 in gang.inc.php 

$this->html .= $this->page->buildElement("gangHome", $gang);

add the following code above

foreach ($gang['members'] as $key => $value) {
	$gang['members'][$key]['underboss'] = ($value['user']['id'] == $g->gang["underboss"] ? 1 : 0);
}

then replace method_setUnderboss() around line 278 with the following code

public function method_setUnderboss() 
{
	if (!$this->user->info->US_gang) return;
	$this->construct = false;
	$gang = new Gang($this->user->info->US_gang);
				
	if ($this->user->id != $gang->gang["boss"]) {
		$this->error("You dont have permission to do this!");
		return $this->method_home();
	}

	$id = (isset($this->methodData->user) ? $this->methodData->user : $gang->gang["underboss"]);
	$newUB = new User($id);		
	$oldUB = new User($gang->gang["underboss"]);

	if ($newUB->id && $newUB->info->US_gang != $this->user->info->US_gang) {
		$this->error("This user is not part of this gang!");
		return $this->method_home();
	}
			
	$ubid = ($oldUB->id == $newUB->id ? 0 : $newUB->id);
	$update = $this->db->prepare("UPDATE gangs SET G_underboss = :ub WHERE G_id = :id");
	$update->bindParam(":ub", $ubid);
	$update->bindParam(":id", $gang->id);
	$update->execute();

	if ($newUB->id != 0 && $newUB->id != $oldUB->id) {
		$newUB->newNotification("You have been promoted to the underboss of " . $gang->gang["name"]);
		$this->error("Underboss updated", "success");
		$gang->log("is now the underboss", $newUB);
	}
			
	if ($oldUB->id != 0) {
		$oldUB->newNotification("You have been demoted from underboss of " . $gang->gang["name"]);
		$this->error("Underboss removal updated", "success");
		$gang->log("was removed as the underboss", $oldUB);
	} 		

	$this->method_home();
}

finally find the following in gangs.tpl.php around line 234

{#if isBoss}
<p>
   <button name="action" value="setUnderboss" class="btn btn-block btn-default">
   Set Underboss
   </button>
</p>
{/if}

replace with 

{#if isBoss}
	<p>
		<button name="action" value="setUnderboss" class="btn btn-block btn-default">
		Set Underboss
    	</button>
	</p>
	{#each members}
	{#if underboss}
	<p>
		<a href="?page=gangs&action=setUnderboss" class="btn btn-block btn-danger">
		Remove Underboss
		</a>
	</p>
	{/if}
	{/each}
{/if}

 

 

Edited by URBANZ
  • Like 1
Link to comment
Share on other sites

  • 2 months later...

What or where do I start with wanting to change the leadership where I can kick the underboss if I am the leader?

Is it really just a matter of removing the highlighted code?

image.png.8db5275ae1256798f64f25a231b135cb.png

yes it does ... at least what I tested anyway

also on line 399 change from gangpermissions to gangPermissions

$permissions = $this->db->prepare("DELETE FROM gangPermissions WHERE GP_user = :u");

I'm also trying to find where I edit the list for edit members like below in gangs, I want to add the underboss to that list when they're set to this as they might do some dodge move and then you may not have someone else to set underboss in replacement:

image.png.5cc1d8ee7c519319638385ac236432a9.png

 

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