szCommand

Started by Alterito, Dec 06, 2015, 06:59 AM

Previous topic - Next topic

Alterito

this system works in 0.4?
function onPlayerCommand( pPlayer, szCommand, szParams )
{
 try
{
local
Players,
Plr,
    PlayersCount  =   GetPlayers(),
szParam1, 
            iParam1,
szParam2,     
iParam2,
    szParam3,   
            iParam3,
szParamA1,   
iParamA1,
szParamA2,
iParamA2,
szParamA3,
iParamA3,
szCmdError    =   szCommand,
        szCommand     =   szCommand.tolower();

if ( szParams )
    {    
szParam1      =   GetTok( szParams, " ", 1 );
iParam1       =   ( szParam1 ? split( szParam1, " ").len() : 0 );
szParam2      =   GetTok( szParams, " ", 2 );
iParam2       =   ( szParam2 ? split( szParam2, " ").len() : 0 );
    szParam3      =   GetTok( szParams, " ", 3 );
iParam3       =   ( szParam3 ? split( szParam3, " ").len() : 0 );
szParamA1     =   GetTok( szParams, " ", 1, NumTok( szParams, " " ) );
iParamA1      =   ( szParamA1 ? split( szParamA1, " ").len() : 0 );
szParamA2     =   GetTok( szParams, " ", 2, NumTok( szParams, " " ) );
iParamA2      =   ( szParamA2 ? split( szParamA2, " ").len() : 0 );
szParamA3     =   GetTok( szParams, " ", 3, NumTok( szParams, " " ) );
iParamA3      =   ( szParamA3 ? split( szParamA3, " ").len() : 0 );

    if ( IsNum( szParam1 ) ) Plr = FindPlayer( szParam1.tointeger() );
else Plr = FindPlayer( szParam1 );
}

for ( local PlayerID = 0, PlayerCount = 0; PlayerID < GetMaxPlayers() && PlayerCount < PlayersCount; PlayerID++ )
    {
if ( !( Players = FindPlayer( PlayerID ) ) ) continue;
    PlayerCount++;
            if ( Players.IsAdmin ) PrivMessage( pPlayer.Name + " Used " + szCommand + " " + szParams, Players );
        }

if ( Stats[ pPlayer.ID ].Leave ) return Announce("\x10 \x10 \x10 \x10 \x10 ~h~!~y~leave" pPlayer );
else if ( szCommand == "test")
    {
try
    {
if ( Stats[ pPlayer.ID ].Registered == true )
    {
if ( Stats[ pPlayer.ID ].Logged == true )
    {
          PrivMessage("Test Started!.." pPlayer );
            {
                Stats[ pPlayer.ID ].Leave = true;
                    MessagePlayer("Teleported To War" pPlayer );
              pPlayer.Skin = 0;
                pPlayer.Team = 0; 
                    pPlayer.Pos = SDMSpawns[ rand() % SDMSpawns.len() ];
Stats[ pPlayer.ID ].AntiHPHack = true;
                    pPlayer.Health += 20;
pPlayer.Armour += 200;
pPlayer.Cash +=300;
            //pPlayer.SetWeapon
                }
PrivMessage("Test Successfully!.." pPlayer );
                    }
                else PrivMessage("[Error] - You're not logged in" pPlayer );
    }
else PrivMessage("[Error] - You're not Registered." pPlayer );
            }        
catch(e) { Print("ERROR - DETECTED....."); Print( Typeof( e ) ); Print( e ); Print("ERROR - END..........."); }
}
else if ( szCommand == "register")
{
if ( Stats[ pPlayer.ID ].Registered == false )
    {
if ( szParams )
    {
    if ( iParamA1 < 2 )
      {
        if ( szParams.len() >= 4 )
    {
            if ( szParams.len() < 18 )
    {
                    if ( szParams != pPlayer.Name )
    {
                    Stats[ pPlayer.ID ].RegisterPlayer( pPlayer, szParams );
                  Stats[ pPlayer.ID ].Deaths = 0;
                Stats[ pPlayer.ID ].Cash = pPlayer.Cash;           
                                    Stats[ pPlayer.ID ].Score = pPlayer.Score;
                Stats[ pPlayer.ID ].User = pPlayer.Name;
                Stats[ pPlayer.ID ].Password = SHA256( szParams );
                Stats[ pPlayer.ID ].Registered = true;
                            Stats[ pPlayer.ID ].Logged = true;
                                PrivMessage("Successfully Registered! /C Help for more Information." pPlayer );
                                PrivMessage("Nick: " + pPlayer.Name + ", Password: " + szParams, pPlayer );
                                ClientMessageToAll(">> " + pPlayer.Name + " is a register Nick-Name now!" 984, 252, 777 );
}
else PrivMessage("[Error] - Your Name Can't be your Password." pPlayer );
                            }
else PrivMessage("[Error] - Password must be under 4 and 18 Characters." pPlayer );
                        }
else PrivMessage("[Error] - Password must be under 4 and 18 Characters." pPlayer );
                    }
        else PrivMessage("[Error] - Password Can't Contain Space!" pPlayer );
}
else PrivMessage("[Syntax] - /c " + szCommand + " <password>" pPlayer );
}
else PrivMessage("[Error] - You're already register!" pPlayer );
}

KAKAN

I think it'll work except the player.IsAdmin thing, as RCON doesn't exist in VCMP 0.4
oh no

Thijn

Jesus christ that code looks horrible. Why don't you just rewrite it?

rww

Join to Irrelevant Club Discord: https://discord.gg/MsPPZ5uV4X

Alterito

Quote from: Thijn on Dec 06, 2015, 09:49 PMJesus christ that code looks horrible. Why don't you just rewrite it?
too much time require :D