/** ** Commands **/ public static function cmdBalance(Player $player, $numparams, $params) { if ($player->location->ID() == LSBank::$id) { $bank = Core::FixIntegerDots($player->GetBank()); $interest = LSBank::$interest; $player->Send(COLOR_BANK_BALANCE, "[BANK] Balance: {$bank}\$, default interests: {$interest}%%"); } return COMMAND_OK; }
public static function OnPlayerEnterVehicle(Player $player, Vehicle $vehicle, $ispassenger) { if (!$ispassenger && $vehicle->Type() == VEHICLE_SHOP) { $price = VehicleShop::$prices[$vehicle->ID()]; $name = $vehicle->Name(); $capacity = $vehicle->FuelSpace(); $usage = sprintf('%.2f', $vehicle->FuelUsage() * 60); $trunk = $vehicle->TrunkSpace(); $player->Send(COLOR_CARSHOP_HEADER, ''); $player->Send(COLOR_CARSHOP_HEADER, '.:: Vehicle shop ::.'); $player->Send(COLOR_CARSHOP_INFO, "This '{$name}' is for sale for {$price}\$"); $player->Send(COLOR_CARSHOP_INFO, 'If you want to buy it, type /buy'); $player->Send(COLOR_CARSHOP_INFO, 'Vehicle details:'); $player->Send(COLOR_CARSHOP_INFO, "* Gas tank capacity: {$capacity}lt"); $player->Send(COLOR_CARSHOP_INFO, "* Fuel usage: {$usage}lt / minute"); $player->Send(COLOR_CARSHOP_INFO, "* Trunk space: {$trunk} units"); $vehicle->SetHealth(1000); return CALLBACK_BREAK; } return CALLBACK_OK; }
public static function cmdCreateVehicle(Player $player, $numparams, $params) { $vehicle = implode(' ', array_slice($params, 1)); $model = -1; if (!ctype_digit($vehicle)) { $model = Vehicles::FindModelidByName($vehicle); } else { if (Vehicles::IsValidModelid($vehicle)) { $model = (int) $vehicle; } else { return COMMAND_OK; } } if ($model != -1) { $pos = clone $player->Position(); $pos->x++; $pos->y++; $pos->z++; new Vehicle(-1, VEHICLE_STATIC, -1, $model, array(1, 0), $pos, 100, 1.1); } else { $player->Send(COLOR_ERROR, '.:: Enter a valid vehicle model ID or name ::.'); } return COMMAND_OK; }
private static function SendUsage(Player $player, $cmdname, $cmd) { if ($cmd->usage != null && !empty($cmd->usage)) { $player->Send(COLOR_USAGE, '[ERROR] Usage: /' . $cmdname . ' ' . $cmd->usage); } }
public static function cmdAdmins(Player $player, $numparams, $params) { $player->Send(COLOR_ADMINLIST, '* Current online admins:'); foreach (Players::Get() as $p) { if ($p->GetAdminLevel() > 0 && Admin::$showadmins[$p->id]) { $player->Send(COLOR_ADMINLIST, " {$p->name} (" . Admin::GetLevelStr($p->GetAdminLevel()) . ')'); } } return COMMAND_OK; }
public static function CheckPayBank(Player $player, Faction $faction, $amount, Faction $target = null) { if ($amount < 1) { $player->Send(COLOR_INVALID_AMOUNT, '[ERROR] Invalid amount'); } else { if ($faction->BankFreezed()) { $player->Send(COLOR_BANK_FREEZED, '[ERROR] Your faction bank account has been freezed, operation not completed'); } else { if ($amount > $faction->GetBank()) { $player->Send(COLOR_NOTENOUGH_MONEYBANK, '[ERROR] Your faction bank account doesn\'t have this amount of money'); } else { if ($target && $target->BankFreezed()) { $player->Send(COLOR_BANK_FREEZED, '[ERROR] Given faction bank account has been freezed, operation cancelled'); } else { return true; } } } } return false; }
public static function menuUpgradesSelect(Player $player, $row) { $skill = Players::GetSkillByName($row); if (!$skill || ($pts = $player->GetUpgradePoints()) == 0) { return; } $nextlevel = $player->GetSkill($skill->flag) + 1; if ($nextlevel <= $skill->maxlevel && $player->GetLevel() >= $skill->reqlevels[$nextlevel] && ($skill->reqskill == -1 || $player->GetSkill($skill->reqskill) >= $skill->reqskill_level)) { $player->SetSkill($skill->flag, $nextlevel); $player->SetUpgradePoints($pts - 1); $player->Send(COLOR_UPGRADE_DONE, "[UGPRADE] You upgraded the skill '{$skill->name}' to the level {$nextlevel}"); } }
public function TransferOwnership(Player $player, Ownership $newowner, $price) { $oldid = $this->GetOwner(); $newid = $newowner->GetOwner(); $oldobj = null; $newobj = null; $oldstats = null; $newstats = null; switch ($this->GetType()) { case OWNERSHIP_ACCOUNT: $oldobj = Players::FindByDBID($oldid); if (!$oldobj) { $oldstats = Accounts::LoadStats($oldid); } if (!$oldobj && !$oldstats) { $player->Send(COLOR_RED, '[ERROR] Internal error, a log of this error has been saved to be fixed'); echo "WARNING! Trying to transfer ownership from an old owner identified as OWNERSHIP_ACCOUNT({$oldid}), " . "but unable to load their stats (account deleted?)\n"; return false; } break; case OWNERSHIP_FACTION: $oldobj = Factions::FindByID($oldid); if (!$oldobj) { $player->Send(COLOR_RED, '[ERROR] Internal error, a log of this error has been saved to be fixed'); echo "WARNING! Trying to transfer ownership from an old owner identified as OWNERSHIP_FACTION({$oldid}), " . "but unable to find the faction (corrupted database?)\n"; return false; } break; } switch ($newowner->GetType()) { case OWNERSHIP_ACCOUNT: $newobj = Players::FindByDBID($newid); if (!$newobj) { $newstats = Accounts::LoadStats($newid); } if (!$newobj && !$newstats) { $player->Send(COLOR_RED, '[ERROR] Internal error, a log of this error has been saved to be fixed'); echo "WARNING! Trying to transfer ownership to a new owner identified as OWNERSHIP_ACCOUNT({$newid}), " . "but unable to load their stats (account deleted?)\n"; return false; } break; case OWNERSHIP_FACTION: $newobj = Factions::FindByID($newid); if (!$newobj) { $player->Send(COLOR_RED, '[ERROR] Internal error, a log of this error has been saved to be fixed'); echo "WARNING! Trying to transfer ownership to a new owner identified as OWNERSHIP_FACTION({$newid}), " . "but unable to find the faction (corrupted database?)\n"; return false; } break; } /* Check if the bank accounts are frozen */ if ($oldobj && $oldobj->BankFreezed()) { $player->Send(COLOR_BANK_FREEZED, '[ERROR] The current owner of this property has his bank account frozen, operation cancelled'); return false; } if ($newobj && $newobj->BankFreezed()) { $facstr = ' '; if ($newobj instanceof Faction) { $facstr = ' faction '; } $player->Send(COLOR_BANK_FREEZED, "[ERROR] Your{$facstr}bank account has been freezed, operation cancelled"); return false; } /* Check if the buyer has enough money */ $facstr = ' '; if ($newobj) { $bank_buyer = $newobj->GetBank(); if ($newobj instanceof Faction) { $facstr = ' faction '; } } else { $bank_buyer = $newstats['bank']; } if ($bank_buyer < $price) { $player->Send(COLOR_NOTENOUGH_MONEYBANK, "[ERROR] Your{$facstr}bank account hasn\\'t enough money to buy this property"); return false; } /* Perform the transaction */ $newname = 'Somebody'; if ($newobj) { $newobj->GiveBank(-$price); $fixed_price = Core::FixIntegerDots($price); if ($newobj instanceof Faction) { $newobj->Send(COLOR_OWNERSHIP_ADQUIRED, "[FACTION BANK] {$player->name} adquired a new property for the faction for {$fixed_price}\$", MEMBER_ALLOWBANK); $newname = $newobj->GetName() . ' faction'; } else { $newobj->Send(COLOR_OWNERSHIP_ADQUIRED, "[BANK] New property adquired for {$fixed_price}\$"); $newname = $newobj->name; } } else { if ($newstats != null) { $newstats['bank'] -= $price; Accounts::SetLoadedStats($newid, $newstats); } } if ($oldobj) { $oldobj->GiveBank($price); $fixed_price = Core::FixIntegerDots($price); if ($oldobj instanceof Faction) { $oldobj->Send(COLOR_OWNERSHIP_SOLD, "[FACTION BANK] {$newname} bought one of the faction properties for sale for {$fixed_price}\$", MEMBER_ALLOWBANK); } else { $oldobj->Send(COLOR_OWNERSHIP_SOLD, "[BANK] {$newname} bought one of your properties for sale for {$fixed_price}\$"); } } else { if ($oldstats != null) { $oldstats['bank'] += $price; Accounts::SetLoadedStats($oldid, $oldstats); } } return true; }
public static function cmdStopexercise(Player $player, $numparams, $params) { if (Gym::$players_key[$player->id] != -1) { SetCameraBehindPlayer($player->id); $player->ClearAnimations(); $player->SetStrength($player->GetStrength() + (int) (Gym::$players_gained[$player->id] / 1)); $player->Send(COLOR_GYM_EARNT, '[GYM] You have earned a total of ' . (int) (Gym::$players_gained[$player->id] / 1) . ' strength points'); Gym::UnregisterPlayer($player); } return COMMAND_OK; }
function getwep(Player $player, $numparams, $params) { $bullets = $player->GetGunAmmo($params[1]); $player->Send(COLOR_YELLOW, "You have {$bullets} bullets of gun {$params[1]}"); return COMMAND_OK; }
public static function cmdCook(Player $player, $numparams, $params) { if ($player->location instanceof House) { $house = $player->location; if (($pos = $house->GetKitchen()) == null) { $player->Send(COLOR_HOUSE_HASNTKITCHEN, '[ERROR] This house doesn\'t have a cooker'); return COMMAND_OK; } if (!$pos->IsInSphere($player->Position(), 2.5)) { $player->Send(COLOR_HOUSE_NOTNEARKITCHEN, '[ERROR] You are not near the cooker'); return COMMAND_OK; } $player->SetMenu(Houses::$cookmenu); } return COMMAND_OK; }
private static function SendWhisper(Player $player, $target, $text) { $playerv = GetPlayerVehicleID($player->id); $targetv = GetPlayerVehicleID($target->id); if ($playerv == 0 || $playerv != $targetv) { if ($player == $target || $player->vworld != $target->vworld || $player->Position()->DistanceTo($target->Position()) > 3.5) { return; } /* Too far or invalid target */ } Log::Append(LOG_MESSAGE, "{WHISPER} [{$player->id}] {$player->name} whispers to {$target->name}[{$target->id}]: {$text}"); $target->Send(COLOR_WHISPER, "{$player->name} whispers: {$text}"); $player->Send(COLOR_WHISPER, "* Whisper sent to {$target->name}: {$text}"); }
public static function cmdLogin(Player $player, $numparams, $params) { if ($player->account->Authed()) { $player->Send(COLOR_GREEN, '* You are already logged in'); return COMMAND_BREAK; } if ($player->account->data['password'] == md5($params[1])) { $player->Send(COLOR_GREEN, '* Password accepted, welcome to ItalyMafia'); $player->account->Auth(); } else { $player->account->wrongpassAttempts--; if ($player->account->wrongpassAttempts == 0) { $player->Send(COLOR_RED, '* Too many invalid passwords!'); Kick($player->id); } else { $player->Send(COLOR_RED, '* Wrong password!'); } } return COMMAND_BREAK; }