Vice City Multiplayer

VC:MP 0.3 => mIRC/pawn Scripting => ShowRoom (pawn) => Topic started by: mrockxkingbutt on April 10, 2013, 07:59:23 am

Title: Reset,Transfer, Inc And Dec Stats By ME (GUPS)
Post by: mrockxkingbutt on April 10, 2013, 07:59:23 am
[pawn]   /// == RESET , == INCREASE, == DECREASE == OR == TRANSFER == STATS == CMDS ===
   else if ( strcmp( cmd, "resetstats", true ) == 0 )
   {
      tmp = strtok( cmdtext, idx ), plr = FindPlayerIDFromString( tmp );
      if ( !IsLoggedIn( playerid ) ) SendClientMessage( playerid, COLOR_RED, "Please log-in to your account." );
      else if ( !IsAuthorized( playerid, cmd ) ) SendClientMessage( playerid, COLOR_RED, "You don't have access to use this command!" );
      else if ( !strlen( tmp ) ) SendClientMessage( playerid, COLOR_RED, "USAGE: /c resetstats [Nick/ID]" );
        else if ( plr == INACTIVE_PLAYER_ID ) SendClientMessage( playerid, COLOR_RED, "Error: Unknown player" );
        else if ( !IsPlayerRegistered(gPlayers[ plr ] ) )
      {
         format( szMsg, sizeof( szMsg ), "Error: %s is not a registered nick.", gPlayers[ plr ] );
         SendClientMessage( playerid, COLOR_GREEN, szMsg );
      }
      else
      {
         format( file, sizeof( file ), USERS_FILE, gPlayers[ plr ] );
         dini_IntSet( file, "Deaths", 0 );
         dini_IntSet( file, "Kills", 0 );
         format( szMsg, sizeof( szMsg ), "%s's stats reseted.", gPlayers[ plr ] );
         SendClientMessage( playerid, COLOR_GREEN, szMsg );
      }
      return 1;
   }
      else if ( strcmp( cmd, "inckills", true ) == 0 )
   {
      tmp = strtok( cmdtext, idx ), plr = FindPlayerIDFromString( tmp );
      if ( !IsLoggedIn( playerid ) ) SendClientMessage( playerid, COLOR_RED, "Please log-in to your account." );
      else if ( !IsAuthorized( playerid, cmd ) ) SendClientMessage( playerid, COLOR_RED, "You don't have access to use this command!" );
      else if ( !strlen( tmp ) ) SendClientMessage( playerid, COLOR_RED, "USAGE: /c inckills [Nick/ID]" );
        else if ( plr == INACTIVE_PLAYER_ID ) SendClientMessage( playerid, COLOR_RED, "Error: Unknown player" );
        else if ( !IsPlayerRegistered(gPlayers[ plr ] ) )
      {
         format( szMsg, sizeof( szMsg ), "Error: %s is not a registered nick.", gPlayers[ plr ] );
         SendClientMessage( playerid, COLOR_GREEN, szMsg );
      }
      else
      {
         IncPlayerDeaths( plr, 0 );
         IncPlayerKills( plr, 1000 );
         format( szMsg, sizeof( szMsg ), "%s's stats Setted", gPlayers[ plr ] );
         SendClientMessage( playerid, COLOR_GREEN, szMsg );
      }
      return 1;
   }
         else if ( strcmp( cmd, "deckills", true ) == 0 )
   {
      tmp = strtok( cmdtext, idx ), plr = FindPlayerIDFromString( tmp );
      if ( !IsLoggedIn( playerid ) ) SendClientMessage( playerid, COLOR_RED, "Please log-in to your account." );
      else if ( !IsAuthorized( playerid, cmd ) ) SendClientMessage( playerid, COLOR_RED, "You don't have access to use this command!" );
      else if ( !strlen( tmp ) ) SendClientMessage( playerid, COLOR_RED, "USAGE: /c deckills [Nick/ID]" );
        else if ( plr == INACTIVE_PLAYER_ID ) SendClientMessage( playerid, COLOR_RED, "Error: Unknown player" );
        else if ( !IsPlayerRegistered(gPlayers[ plr ] ) )
      {
         format( szMsg, sizeof( szMsg ), "Error: %s is not a registered nick.", gPlayers[ plr ] );
         SendClientMessage( playerid, COLOR_GREEN, szMsg );
      }
      else
      {
         IncPlayerDeaths( plr, 1000 );
         IncPlayerKills( plr, 0 );
         format( szMsg, sizeof( szMsg ), "%s's stats Setted", gPlayers[ plr ] );
         SendClientMessage( playerid, COLOR_GREEN, szMsg );
      }
      return 1;
   }
      else if ( strcmp( cmd, "transferstats", true ) == 0 )
   {
   new plr2;
      tmp = strtok( cmdtext, idx ), plr = FindPlayerIDFromString( tmp );
      plr2 = FindPlayerIDFromString( tmp );
      if ( !IsLoggedIn( playerid ) ) SendClientMessage( playerid, COLOR_RED, "Please log-in to your account." );
      else if ( !IsAuthorized( playerid, cmd ) ) SendClientMessage( playerid, COLOR_RED, "You don't have access to use this command!" );
      else if ( !strlen( tmp ) ) SendClientMessage( playerid, COLOR_RED, "USAGE: /c transferstats [Nick/ID] [PLAYERID2]" );
        else if ( plr == INACTIVE_PLAYER_ID ) SendClientMessage( playerid, COLOR_RED, "Error: Unknown player" );
        else if ( !IsPlayerRegistered(gPlayers[ plr ] )) SendClientMessage(playerid, COLOR_RED, " DOES NOT REGISTERED ");
        else if ( !IsPlayerRegistered(gPlayers[ plr2 ] )) SendClientMessage(playerid, COLOR_RED, " DOES NOT REGISTERED ");
      else
      {
         format( file, sizeof( file ), USERS_FILE, gPlayers[ plr ] );
         dini_IntSet( file, "Deaths", 0 );
         dini_IntSet( file, "Kills", 0 );
         format( szMsg, sizeof( szMsg ), "%s's stats reseted.", gPlayers[ plr ] );
         SendClientMessage( playerid, COLOR_GREEN, szMsg );
format( file, sizeof( file ), USERS_FILE, gPlayers[ plr ] );
Kill = dini_Get( file, "Kills");
Death = dini_Get( file, "Deaths");
         format( file, sizeof( file ), USERS_FILE, gPlayers[ plr2 ] );
dini_IntSet( file, "Kills", Kill[plr] );
dini_IntSet( file, "Deaths", Death[plr] );
         format( szMsg, sizeof( szMsg ), "%s's stats transfered", gPlayers[ plr ] );
         SendClientMessage( playerid, COLOR_GREEN, szMsg );
      }
      
      return 1;
   }[/pawn]
Title: Re: Reset,Transfer, Inc And Dec Stats By ME (GUPS)
Post by: dynavolt71 on April 10, 2013, 08:09:37 am
But Data Players That Were There.
Title: Re: Reset,Transfer, Inc And Dec Stats By ME (GUPS)
Post by: stormeus on April 10, 2013, 01:42:30 pm
Quote
[pawn]
format( file, sizeof( file ), USERS_FILE, gPlayers[ plr ] );
dini_IntSet( file, "Deaths", 0 );
dini_IntSet( file, "Kills", 0 );
format( szMsg, sizeof( szMsg ), "%s's stats reseted.", gPlayers[ plr ] );
SendClientMessage( playerid, COLOR_GREEN, szMsg );

format( file, sizeof( file ), USERS_FILE, gPlayers[ plr ] );
Kill = dini_Get( file, "Kills");
Death = dini_Get( file, "Deaths");

format( file, sizeof( file ), USERS_FILE, gPlayers[ plr2 ] );
dini_IntSet( file, "Kills", Kill[plr] );
dini_IntSet( file, "Deaths", Death[plr] );
[/pawn]

All of the transferred stats will just be equal to 0 because you reset the stats before saving them in a variable. Also, why are you using an array for the variables Kill and Death? Lastly, you didn't even create the variables Kill and Death, unless you made a new array at the top of the script, in which case you're still using it wrong because of this:
Quote
[pawn]
Kill = dini_Get( file, "Kills");
Death = dini_Get( file, "Deaths");
[/pawn]

That part should be:
[pawn]
format( file, sizeof( file ), USERS_FILE, gPlayers[ plr ] );
new Kill = dini_Get( file, "Kills");
new Death = dini_Get( file, "Deaths");
dini_IntSet( file, "Deaths", 0 );
dini_IntSet( file, "Kills", 0 );

format( szMsg, sizeof( szMsg ), "%s's stats reset.", gPlayers[ plr ] );
SendClientMessage( playerid, COLOR_GREEN, szMsg );

format( file, sizeof( file ), USERS_FILE, gPlayers[ plr2 ] );
dini_IntSet( file, "Kills", Kill );
dini_IntSet( file, "Deaths", Death );
[/pawn]

I didn't even bother checking the rest of the script thoroughly because this was the most obvious, but test your scripts before posting them or you won't be allowed to post them.
Title: Re: Reset,Transfer, Inc And Dec Stats By ME (GUPS)
Post by: aledark24 on April 10, 2013, 05:21:50 pm
 :o :o :o another failed command...




note: today is my birthday....
Title: Re: Reset,Transfer, Inc And Dec Stats By ME (GUPS)
Post by: sseebbyy on April 10, 2013, 06:01:05 pm
note: today is my birthday....

OFF:

Happy Birthday :P
Title: Re: Reset,Transfer, Inc And Dec Stats By ME (GUPS)
Post by: NeskWriter on April 10, 2013, 08:55:15 pm
note: today is my birthday....

Happy Birthday, aledark ) I've loggen-in my account especially to congratulate you, dude =)
Mrock, I see you won't start making more useful functions. This is useless because it's useless <- because it's useless. It's time to evolve, dude