09.12.2013, 02:55
pawn Код:
new TiempoRegalo[MAX_PLAYERS];
new TiempoRega;
zcmd(abrirregalo, playerid, params[])
{
if(TiempoRegalo[playerid] <= 0)
{
DarHeroinaRandom(playerid);
}
else
{
format(string, sizeof(string), "Te faltan %d minutos para volver a abrir el regalo!", TiempoRegalo[playerid]);
SendClientMessage(playerid,-1,string);
}
return 1;
}
stock DarHeroinaRandom(playerid)
{
new azar = random(5);
switch(azar)
{
case 0:
{
PlayerInfo[playerid][pHeroina] += 1;
Message(playerid, COLOR_WHITE, "* Has recibido 1 gramo de heroina");
}
case 1:
{
PlayerInfo[playerid][pHeroina] += 2;
Message(playerid, COLOR_WHITE, "* Has recibido 2 gramo de heroina");
}
case 2:
{
PlayerInfo[playerid][pHeroina] += 3;
Message(playerid, COLOR_WHITE, "* Has recibido 3 gramo de heroina");
}
case 3:
{
PlayerInfo[playerid][pHeroina] += 4;
Message(playerid, COLOR_WHITE, "* Has recibido 4 gramo de heroina");
}
case 4:
{
PlayerInfo[playerid][pHeroina] += 5;
Message(playerid, COLOR_WHITE, "* Has recibido 5 gramo de heroina");
}
TiempoRegalo[playerid] = 60;
}
return 1;
}
public OnGameModeInit()
{
TiempoRega = SetTimer("DisminuirTiempo", 1000*60, true);
return 1;
}
forward DisminuirTiempo();
public DisminuirTiempo()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i))
{
if(TiempoRegalo[i] > 0)
{
TiempoRegalo[i] -= 1;
}
}
}
return 1;
}
public OnGameModeExit()
{
KillTimer(TiempoRega);
return 1;
}