pawn Код:
#include a_samp
#include YSI\y_commands
#include sscanf2
new
int_candy_price [ MAX_PLAYERS ],
int_player_candy [ MAX_PLAYERS ],
id_seller [ MAX_PLAYERS ],
id_buyer [ MAX_PLAYERS ],
bool: boo_candy_invite [ MAX_PLAYERS ];
YCMD:venderbala(playerid, params[], help)
{
new
targetid,
int_price;
if ( sscanf ( params, "ud", targetid, int_price ) )
return SendClientMessage ( playerid, -1, "Utilize /venderbala [userid] [preзo]" );
if ( !IsPlayerConnected ( targetid ) || targetid == INVALID_PLAYER_ID )
return SendClientMessage ( playerid, -1, "Jogador nгo encontrado!" );
else if ( int_player_candy [ targetid ] >= 7 )
return SendClientMessage ( playerid, -1, "Esse jogador jб tem 7 balas!" );
else if ( targetid == playerid )
return SendClientMessage ( playerid, -1, "Vocк nгo pode vender balas para vocк mesmo." );
id_seller [ targetid ] = playerid;
id_buyer [ playerid ] = targetid;
boo_candy_invite [ targetid ] = true;
int_candy_price [ targetid ] = int_price;
new
str_candy_msg [ 113 ],
str_playerid_name [ MAX_PLAYER_NAME ];
GetPlayerName ( playerid, str_playerid_name, MAX_PLAYER_NAME );
format ( str_candy_msg, sizeof str_candy_msg, "O jogador %s estб te oferecendo 1 bala por $%d. Vocк deseja aceitar? (/aceitarbala)", str_playerid_name, int_price );
SendClientMessage ( targetid, -1, str_candy_msg );
return 1;
}
YCMD:aceitarbala(playerid, params[], help)
{
if ( !boo_candy_invite [ playerid ] )
return SendClientMessage ( playerid, -1, "Nгo tem ninguйm te oferecendo bala" );
else if ( !IsPlayerConnected ( id_seller [ playerid ] ) || id_seller [ playerid ] == INVALID_PLAYER_ID )
return SendClientMessage ( playerid, -1, "O jogador que te ofereceu a bala se desconectou!" );
else if ( GetPlayerMoney ( playerid ) < int_candy_price [ playerid ] )
return SendClientMessage ( playerid, -1, "Vocк nгo tem dinheiro o suficiente para aceitar a bala!" );
GivePlayerMoney ( playerid, -int_candy_price [ playerid ] );
GivePlayerMoney ( id_seller [ playerid ], int_candy_price [ playerid ] );
int_player_candy [ playerid ] ++;
boo_candy_invite [ playerid ] = false;
SendClientMessage ( playerid, -1, "Vocк aceitou a bala e pode jб pode come-la! (/comerbala)" );
new
str_msg [ 50 ];
format ( str_msg, sizeof str_msg, "O jogador aceitou a bala e vocк recebeu $%d!", int_candy_price [ playerid ] );
SendClientMessage ( id_seller [ playerid ], -1, str_msg );
return 1;
}
YCMD:comerbala(playerid, params[], help)
{
if ( int_player_candy [ playerid ] == 0 )
return SendClientMessage ( playerid, -1, "Vocк nгo tem nenhuma bala pra comer ):" );
int_player_candy [ playerid ]--;
if ( int_player_candy [ playerid ] > 0)
{
new
str_msg [ 47 ];
format ( str_msg, sizeof str_msg, "Vocк comeu 1 bala, agora sу te restaram %d!", int_player_candy [ playerid ] );
SendClientMessage ( playerid, -1, str_msg );
return 1;
}
else if ( int_player_candy [ playerid ] == 0 )
return SendClientMessage ( playerid, -1, "Vocк comeu sua ъltima bala, por que nгo compra mais algumas? :)");
return 1;
}