Advertisement
KaLu17

Untitled

Apr 20th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.64 KB | None | 0 0
  1. <?php
  2. class public_samp_game_create extends ipsCommand
  3. {
  4.     public function doExecute( ipsRegistry $registry )
  5.     {
  6.         if(!$this->memberData['member_id'])
  7.         {
  8.             $this->registry->output->showError('Aby móc przeglądać tą zakładkę, musisz się zalogować.',0);
  9.         }
  10.        
  11.         if(isset($this->request['create_char']))
  12.         {
  13.             if($this->request['charsex'] != 1 && $this->request['charsex'] != 0)
  14.             {
  15.                 $this->registry->output->showError('Płeć postaci nie została wybrana lub jest błędna.', 0);
  16.             }  
  17.  
  18.             $create_name    = $this->DB->addSlashes($this->request['charname']);
  19.            
  20.             $this->DB->query("SELECT char_name FROM hia_players WHERE char_name LIKE '".$this->DB->addSlashes($this->request['charname'])."'");
  21.             if($this->DB->getTotalRows() > 0)
  22.             {
  23.                 $existing = $this->DB->fetch();
  24.                 $this->registry->output->showError('Postać podobna do tej, jest własnością innego gracza.', 0);
  25.             }
  26.            
  27.             if(!empty($this->request['charname']) && !preg_match('~[A-Z][a-z]*~',$this->request['charname']))
  28.             {
  29.                 $this->registry->output->showError('Podana przez Ciebie nazwa postaci jest błędna.', 0);
  30.             }
  31.                
  32.             $create_age     = trim(2013 - intval($this->request['charage']));
  33.             $create_sex     = trim(intval($this->request['charsex']));
  34.             $create_gid     = trim(intval($this->memberData['member_id']));
  35.             $create_skin    = trim(intval($this->request['skin']));
  36.             $this->DB->insert( "players", array( 'char_name' => $create_name, 'char_sex' => $create_sex, 'char_age' => $create_age, 'char_gid' => $create_gid, 'char_skin' => $create_skin  ) );
  37.            
  38.             $create_name = str_replace("_", " ", $create_name);
  39.            
  40.             $this->registry->output->redirectScreen( 'Utworzyłeś postać '.$create_name.'.', $this->settings['base_url'] . 'app=samp' );
  41.         }
  42.        
  43.         $this->DB->query('SELECT * FROM `hia_players` WHERE `char_gid` = '.$this->memberData['member_id'].' AND `char_online` < 18000 LIMIT 1');   
  44.         $this->DB->execute();
  45.         $char = $this->DB->fetch();
  46.         if(!$char['char_uid'] || $this->memberData['member_group_id'] == 4)
  47.         {
  48.             $this->DB->query('SELECT * FROM `hia_skins_samp`');
  49.             $this->DB->execute();  
  50.             while($skin = $this->DB->fetch())
  51.             {      
  52.                 $skins[] = $skin;
  53.             }
  54.            
  55.             $template = $this->registry->output->getTemplate('game')->game_create($skins);
  56.             $this->registry->getClass('output')->addContent($template);
  57.             $this->registry->output->setTitle('Kreator postaci');
  58.             $this->registry->output->addNavigation( 'Kreator postaci', 'app=samp&module=game&section=create' );
  59.             $this->registry->getClass('output')->sendOutput();
  60.         }
  61.         else
  62.         {  
  63.             $this->registry->output->showError('Nie możesz założyć kolejnej postaci.',0);
  64.  
  65.         }
  66.        
  67.     }
  68. }
  69. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement