13.01.2014, 22:48
Tenнas sscanf al pedo .
pawn Код:
/*------------------------------------------------------------------------------
*
* [FS] Sistema de Recompensas
*
* Por Ari3l
*
-*----------------------------------------------------------------------------*/
#include <a_samp>
#include <zcmd> // Por Zeex
#include <sscanf2> // Por ******
/*----------------------------------------------------------------------------*/
new Cantidad[MAX_PLAYERS];
/*----------------------------------------------------------------------------*/
public OnFilterScriptInit()
{
new dma[3], hms[3];
getdate(dma[2], dma[1], dma[0]);
gettime(hms[0], hms[1], hms[2]);
print("\n---------------------------------------------------" );
print( " [FS]Sistema de Recompensas - Encendido - Por Ari3l" );
print( "---------------------------------------------------" );
printf( " Fecha: %i-%i-%i Hora: %i:%i:%i", dma[0], dma[1], dma[2], hms[0], hms[1], hms[2]);
print( "---------------------------------------------------\n" );
for(new i = 0; i < GetMaxPlayers(); i++)
{
Cantidad[i] = 0;
}
return 1;
}
/*----------------------------------------------------------------------------*/
public OnFilterScriptExit()
{
new dma[3], hms[3];
getdate(dma[2], dma[1], dma[0]);
gettime(hms[0], hms[1], hms[2]);
print("\n---------------------------------------------------" );
print( " [FS]Sistema de Recompensas - Apagado - Por Ari3l" );
print( "---------------------------------------------------" );
printf( " Fecha: %i-%i-%i Hora: %i:%i:%i",dma[0], dma[1], dma[2], hms[0], hms[1], hms[2]);
print( "---------------------------------------------------\n" );
return 1;
}
/*----------------------------------------------------------------------------*/
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID)
{
if(Cantidad[playerid] > 0 && killerid != playerid)
{
new string[128];
format(string, sizeof(string), "[RECOMPENSA] %s ah Recibido la recompensa de $%i por Matar ah %s", pNombre(killerid), Cantidad[playerid], pNombre(playerid));
SendClientMessageToAll( -1 , string);
GivePlayerMoney(killerid, Cantidad[playerid]);
Cantidad[playerid] = 0;
}
}
return 1;
}
/*----------------------------------------------------------------------------*/
CMD:recompensa(playerid, params[])
{
if(sscanf(params, "di", params[0], params[1]))
{
SendClientMessage( playerid, -1, "Uso: /recompensa [playerid] [recompensa]");
SendClientMessage( playerid, -1, "Info: Pon recompensa por la cabeza de otro player.");
}
else if(!IsPlayerConnected(params[0])) SendClientMessage(playerid, -1, "ERROR: PlayerID no conectado");
else if(params[0] <= 0 || params[0] > GetPlayerMoney(playerid)) SendClientMessage( playerid, -1, "ERROR: Recompensa Invalida");
else
{
new string[128];
Cantidad[ID] += params[0];
GivePlayerMoney(playerid, -Recompensa);
format(string,sizeof(string),"[RECOMPENSA] - %s ah Puesto $%i de Recompensa por la Cabeza de %s. [Total: $%i]", pNombre(playerid), Recompensa, pNombre(ID), Cantidad[ID]);
SendClientMessageToAll( -1, string);
}
return 1;
}
// ---------------------------------
CMD:recompensas(playerid, params[])
{
new string[256], count;
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i))
{
if(Cantidad[i] > 0)
{
count ++;
if(count >= 1)
{
format( string, sizeof(string),"- %s - Total [$%i]\n", pNombre(i), Cantidad[i]);
ShowPlayerDialog(playerid, 4526, DIALOG_STYLE_MSGBOX, "Recompensas", string, "Aceptar","");
}
else
{
SendClientMessage(playerid, -1, "No hay Recompensas.");
}
}
}
}
return 1;
}
/*----------------------------------------------------------------------------*/
stock pNombre(playerid)
{
new Nombre[MAX_PLAYER_NAME];
GetPlayerName(playerid, Nombre, sizeof(Nombre));
return Nombre;
}