Vice City Multiplayer

VC:MP 0.3 => mIRC/pawn Scripting => Topic started by: VC[88]PD on February 09, 2013, 10:29:44 am

Title: [Command Question][Need help with givecash]
Post by: VC[88]PD on February 09, 2013, 10:29:44 am
Hi,all,I need help again.I made this command but it have many errors.Can you help me?
[pawn]    else if (strcmp(cmd, "!givecash", true) == 0)
   {
          tmp = strtok(cmdtext, idx);
        new len = strlen(tmp);
        new plr;
        plr = FindPlayerIDFromString(tmp);
         if (!len) { format(szMsg,sizeof(szMsg),"Usage: !givecash [playerid] [100/500/1000].",tmp);SendClientMessage(playerid, COLOR_GREY, szMsg);return 1;}
         else if ( plr == INACTIVE_PLAYER_ID ) SendClientMessage( playerid, COLOR_RED, "Error: Unknown player" );
         else {
            if(strcmp(tmp, "100", true) == 0)
          {
         if {(GetPlayerMoney(playerid) < 100) SendClientMessage( playerid, COLOR_GREEN, "Error: You havent got the needed money." );return 1;}
         else{
        SetPlayerMoney(plr, GetPlayerMoney(plr) + 100);
        SetPlayerMoney(playerid, GetPlayerMoney(playerid) - 100);
        format(szMsg,256,"%s has use !givecash to given %s [100].",gPlayers[ playerid ],gPlayers[ plr ]);
          SendClientMessageToAll(COLOR_LIGHTBLUE, szMsg);
        }
        return 1;
        }
          else if(strcmp(tmp, "500", true) == 0)
         {
             if {(GetPlayerMoney(playerid) < 500) SendClientMessage( playerid, COLOR_GREEN, "Error: You havent got the needed money." );return 1;}
         else{
          SetPlayerMoney(plr, GetPlayerMoney(plr) + 500);
        SetPlayerMoney(playerid, GetPlayerMoney(playerid) - 500);
        format(szMsg,256,"%s has use !givecash to given %s [500].",gPlayers[ playerid ],gPlayers[ plr ]);
          SendClientMessageToAll(COLOR_LIGHTBLUE, szMsg);
          }
          return 1;
          }
         else if(strcmp(tmp, "1000", true) == 0)
         {
         if {(GetPlayerMoney(playerid) < 1000) SendClientMessage( playerid, COLOR_GREEN, "Error: You havent got the needed money." );return 1;}
         else{
             SetPlayerMoney(plr, GetPlayerMoney(plr) + 1000);
        SetPlayerMoney(playerid, GetPlayerMoney(playerid) - 1000);
        format(szMsg,256,"%s has use !givecash to given %s [1000].",gPlayers[ playerid ],gPlayers[ plr ]);
          SendClientMessageToAll(COLOR_LIGHTBLUE, szMsg);
          }
          return 1;
          }
        }
       return 1;
   }[/pawn]

errors:
Code: [Select]
D:\VCMP JIANFU2\gamemodes\mode.pwn(1744) : error 001: expected token: "(", but found "{"
D:\VCMP JIANFU2\gamemodes\mode.pwn(1753) : error 029: invalid expression, assumed zero
D:\VCMP JIANFU2\gamemodes\mode.pwn(1753) : warning 215: expression has no effect
D:\VCMP JIANFU2\gamemodes\mode.pwn(1753) : error 001: expected token: ";", but found "if"
D:\VCMP JIANFU2\gamemodes\mode.pwn(1755) : error 001: expected token: "(", but found "{"
D:\VCMP JIANFU2\gamemodes\mode.pwn(1766) : error 001: expected token: "(", but found "{"
D:\VCMP JIANFU2\gamemodes\mode.pwn(1768) : error 017: undefined symbol "plr"
D:\VCMP JIANFU2\gamemodes\mode.pwn(1770) : error 017: undefined symbol "plr"
D:\VCMP JIANFU2\gamemodes\mode.pwn(1775) : error 054: unmatched closing brace
D:\VCMP JIANFU2\gamemodes\mode.pwn(1776) : error 010: invalid function or declaration
D:\VCMP JIANFU2\gamemodes\mode.pwn(1778) : error 010: invalid function or declaration
Can you help me?
thanks
Title: Re: [Command Question][Need help with givecash]
Post by: VC[88]PD on February 09, 2013, 07:57:05 pm
Who can help me!
Title: Re: [Command Question][Need help with givecash]
Post by: NeskWriter on February 10, 2013, 01:11:49 am
I'llhelp u tomorrow, now I'm going to sleep  ::)
Title: Re: [Command Question][Need help with givecash]
Post by: dynavolt71 on February 10, 2013, 03:08:31 am
Who can help me!
Wait for a min i will help u (cause i cant see prob on my phone)
Hell I Cant see The Line  :o
EDITED : Its Create My Pawno Library Crash
Title: Re: [Command Question][Need help with givecash]
Post by: mrockxkingbutt on February 10, 2013, 03:11:11 pm
use simple
[pawn]      else if ( strcmp( cmd, "!givecash", true ) == 0 )
   {
          new tmp2[ 256 ], plr;
      tmp = strtok( cmdtext, idx ), tmp2 = strtok( cmdtext, idx ), plr = FindPlayerIDFromString( tmp );
      if ( !IsLoggedIn( playerid ) ) SendClientMessage( playerid, COLOR_RED, "Please log-in to your account." );
      else if ( !strlen(tmp2) ) SendClientMessage( playerid, COLOR_GREEN, "USAGE: !givecash [Nick/ID] [Amount]" );
      else if (GetPlayerHandCash(gPlayers[ playerid ]) < StrToInt(tmp2) ) SendClientMessage( playerid, COLOR_GREEN, "Error: You havent got the needed money." );
      else if ( plr != INACTIVE_PLAYER_ID ) SendClientMessage( playerid, COLOR_RED, "Error: Unknown player" );
      else if ( !IsPlayerRegistered(gPlayers[ plr ]) ) SendClientMessage( playerid, COLOR_RED, "Error: That nick is not registered!" );
      else if ( !IsNumeric(tmp2) ) SendClientMessage( playerid, COLOR_GREEN, "Error: Invalid Amount!" );
      else
      {
         format( szMsg, sizeof( szMsg ), "You have sent:[ $%d ] to:[ %s ]",tmp, gPlayers[ playerid ] );
         SendClientMessage( playerid, COLOR_GREEN, szMsg );
         DecPlayerHandCash( playerid,StrToInt( tmp ) );
         IncPlayerHandCash( plr,StrToInt( tmp ) );
      }
      return 1;
      }[/pawn]
Title: Re: [Command Question][Need help with givecash]
Post by: VC[88]PD on February 10, 2013, 07:18:57 pm
use simple
[pawn]      else if ( strcmp( cmd, "!givecash", true ) == 0 )
   {
          new tmp2[ 256 ], plr;
      tmp = strtok( cmdtext, idx ), tmp2 = strtok( cmdtext, idx ), plr = FindPlayerIDFromString( tmp );
      if ( !IsLoggedIn( playerid ) ) SendClientMessage( playerid, COLOR_RED, "Please log-in to your account." );
      else if ( !strlen(tmp2) ) SendClientMessage( playerid, COLOR_GREEN, "USAGE: !givecash [Nick/ID] [Amount]" );
      else if (GetPlayerHandCash(gPlayers[ playerid ]) < StrToInt(tmp2) ) SendClientMessage( playerid, COLOR_GREEN, "Error: You havent got the needed money." );
      else if ( plr != INACTIVE_PLAYER_ID ) SendClientMessage( playerid, COLOR_RED, "Error: Unknown player" );
      else if ( !IsPlayerRegistered(gPlayers[ plr ]) ) SendClientMessage( playerid, COLOR_RED, "Error: That nick is not registered!" );
      else if ( !IsNumeric(tmp2) ) SendClientMessage( playerid, COLOR_GREEN, "Error: Invalid Amount!" );
      else
      {
         format( szMsg, sizeof( szMsg ), "You have sent:[ $%d ] to:[ %s ]",tmp, gPlayers[ playerid ] );
         SendClientMessage( playerid, COLOR_GREEN, szMsg );
         DecPlayerHandCash( playerid,StrToInt( tmp ) );
         IncPlayerHandCash( plr,StrToInt( tmp ) );
      }
      return 1;
      }[/pawn]
But I haven't used GUPS!!
[/color]
Title: Re: [Command Question][Need help with givecash]
Post by: JaVeD on February 11, 2013, 06:21:42 am
Put the GUPS !givecash script in your server and compile then show me what error coming then we fix it this is not good givecash scrip dont use >100 >1000 or else use tmp what ammount player want to give to someone :D TRy that script :

[pawn]else if ( strcmp( cmd, "!givecash", true ) == 0 )
   {
          new tmp2[ 256 ], plr;
      tmp = strtok( cmdtext, idx ), tmp2 = strtok( cmdtext, idx ), plr = FindPlayerIDFromString( tmp );
      if ( !IsLoggedIn( playerid ) ) SendClientMessage( playerid, COLOR_GREEN, "Please log-in to your account." );
      else if ( !strlen(tmp2) ) SendClientMessage( playerid, COLOR_YELLOW, "USAGE: !givecash [Nick/ID] [Amount]" );
      else if (GetPlayerHandCash(gPlayers[ playerid ]) < StrToInt(tmp2) ) SendClientMessage( playerid, ORANGE, "You havent got the needed money." );
      else if ( plr == INACTIVE_PLAYER_ID ) SendClientMessage( playerid, COLOR_RED, "Error: Unknown player" );
      else if ( !IsPlayerRegistered(gPlayers[ plr ]) ) SendClientMessage( playerid, GREEN, "That nick is not registered!" );
      else if ( !IsNumeric(tmp2) ) SendClientMessage( playerid, COLOR_RED, "Invalid Amount!" );
      else
      {
         format( szMsg, sizeof( szMsg ), "You have sent:[ $%d ] to:[ %s ]",tmp, gPlayers[ playerid ] );
         SendClientMessage( playerid, GREEN, szMsg );
         DecPlayerHandCash( playerid,StrToInt( tmp ) );
         IncPlayerHandCash( plr,StrToInt( tmp ) );
      }
      return 1;
      }[/pawn]
Title: Re: [Command Question][Need help with givecash]
Post by: dynavolt71 on February 11, 2013, 10:32:31 am
IsLoggedIn
IsPlayerRegistered
DecPlayerHandCash( playerid,StrToInt( tmp ) );
IncPlayerHandCash( plr,StrToInt( tmp ) );


This Function Is FORM GUPS But Im Not Sure

Title: Re: [Command Question][Need help with givecash]
Post by: VC[88]PD on February 11, 2013, 10:42:39 am
Put the GUPS !givecash script in your server and compile then show me what error coming then we fix it this is not good givecash scrip dont use >100 >1000 or else use tmp what ammount player want to give to someone :D TRy that script :

[pawn]else if ( strcmp( cmd, "!givecash", true ) == 0 )
   {
          new tmp2[ 256 ], plr;
      tmp = strtok( cmdtext, idx ), tmp2 = strtok( cmdtext, idx ), plr = FindPlayerIDFromString( tmp );
      if ( !IsLoggedIn( playerid ) ) SendClientMessage( playerid, COLOR_GREEN, "Please log-in to your account." );
      else if ( !strlen(tmp2) ) SendClientMessage( playerid, COLOR_YELLOW, "USAGE: !givecash [Nick/ID] [Amount]" );
      else if (GetPlayerHandCash(gPlayers[ playerid ]) < StrToInt(tmp2) ) SendClientMessage( playerid, ORANGE, "You havent got the needed money." );
      else if ( plr == INACTIVE_PLAYER_ID ) SendClientMessage( playerid, COLOR_RED, "Error: Unknown player" );
      else if ( !IsPlayerRegistered(gPlayers[ plr ]) ) SendClientMessage( playerid, GREEN, "That nick is not registered!" );
      else if ( !IsNumeric(tmp2) ) SendClientMessage( playerid, COLOR_RED, "Invalid Amount!" );
      else
      {
         format( szMsg, sizeof( szMsg ), "You have sent:[ $%d ] to:[ %s ]",tmp, gPlayers[ playerid ] );
         SendClientMessage( playerid, GREEN, szMsg );
         DecPlayerHandCash( playerid,StrToInt( tmp ) );
         IncPlayerHandCash( plr,StrToInt( tmp ) );
      }
      return 1;
      }[/pawn]
D:\VCMP JIANFU2\gamemodes\mode.pwn(1787) : error 017: undefined symbol "IsLoggedIn"
D:\VCMP JIANFU2\gamemodes\mode.pwn(1789) : error 017: undefined symbol "GetPlayerHandCash"
D:\VCMP JIANFU2\gamemodes\mode.pwn(1791) : error 017: undefined symbol "IsPlayerRegistered"
D:\VCMP JIANFU2\gamemodes\mode.pwn(1792) : error 017: undefined symbol "IsNumeric"
D:\VCMP JIANFU2\gamemodes\mode.pwn(1797) : error 017: undefined symbol "DecPlayerHandCash"
D:\VCMP JIANFU2\gamemodes\mode.pwn(1798) : error 017: undefined symbol "IncPlayerHandCash"
Title: Re: [Command Question][Need help with givecash]
Post by: JaVeD on February 11, 2013, 10:57:23 am
PUT THIS IN PUBLIC

[pawn]
public GetPlayerHandCash( player[] )
{
   new xg;
   format( file, sizeof( file ), USERS_FILE, player);
   xg = dini_Int( file, "Cash" );
   return xg;
}
public DecPlayerHandCash( playerid, Amount )
{
   format( file, sizeof( file ), USERS_FILE, gPlayers[ playerid ] );
   new cash; cash = dini_Int( file, "Cash" );
   dini_IntSet( file, "Cash", cash -Amount);
   SetPlayerMoney( playerid,GetPlayerHandCash(gPlayers[ playerid ]) );
}

public IncPlayerHandCash( playerid, Amount )
{
   format( file, sizeof( file ), USERS_FILE, gPlayers[ playerid ] );
   new cash; cash = dini_Int( file, "Cash" );
   dini_IntSet( file, "Cash", cash +Amount);
   SetPlayerMoney( playerid,GetPlayerHandCash(gPlayers[ playerid ]) );
}
isnumeric( const string[] )
{// mike's function
   for ( new i = 0, j = strlen( string ); i < j; i++ ) { if ( string[ i ] > '9' || string[ i ] < '0' ) return 0; }
   return 1;
}[/pawn]

And on stock
[pawn]stock IsNumeric( string[] ) { for (new i = 0, j = strlen( string ); i < j; i++ ) if ( string > '9' || string < '0') return 0; return 1; }

stock IsLoggedIn( id )
{
   return ( PlayerInfo[ id ][ Logged ] == 1 ) ? true : false;
}[/pawn]

[pawn]stock IsRegistered( id )
{
   return ( PlayerInfo[ id ][ Logged ] == 2 ) ? true : false;
}

stock IsPlayerRegistered( player[] )
{ // We need to give the full nick name.
   format( file, sizeof( file ), USERS_FILE, player);
   return ( dini_Exists( file ) ) ? true : false;
}[/pawn]

Note: u can edit the file locations like where is your user file and cash ini edit and put ur script cash location and i hope it will be work :D
Title: Re: [Command Question][Need help with givecash]
Post by: aledark24 on February 11, 2013, 10:30:45 pm
yeah is givecash of gups... but not working because use 2 tmp and need tmp and tmp2 to send to another player xD


another time i help you now i posted how change ban system of gups xD