07.06.2011, 19:50
PHP код:
#include <Dini>
new Bomba[MAX_PLAYERS];
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/comprarbomba", cmdtext, true, 10) == 0)
{
if(GetPlayerMoney(playerid)<50000)return SendClientMessage(playerid, AZULCLARINHO,"{FF5959}| ERRO |{FFFFFF} Vocк Nгo Tem {FF5959}${FFFFFF}50000!");
SetPlayerAttachedObject(playerid,2,1654,1,0.1000,0.2000,0.0000,0.0,90.0000,180.0000);
GivePlayerMoney(playerid, -50000);
SendClientMessage(playerid, BRANCO,"{FF5959}| INFO |{FFFFFF} Vocк Comprou Uma Bomba!");
Bomba[playerid] ++;
return 1;
}
if(strcmp("/explodirbomba", cmdtext, true, 10) == 0)
{
if(Bomba[playerid] == 0) return SendClientMessage(playerid, BRANCO,"Vocк nгo comprou nenhuma bomba !");
Bomba[playerid] --;
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
CreateExplosion(x, y, z, 11, 10.0);
SendClientMessage(playerid, BRANCO,"{FF5959}| INFO |{FFFFFF} Vocк Se Explodiu! {FF5959}RAIIRAIRAIIRAIAR{FFFFFF}");
return 1;
}
return 0;
}
public OnPlayerConnect(playerid)
{
new save[40], n[24];
GetPlayerName(playerid, n, 24);
format(save, 40, "/Acc/%s.txt",n);
if(fexist(save))
{
Bomba[playerid] = dini_Int(save, "Bombas");
}
else
{
dini_Create(save);
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new save[40], n[24];
GetPlayerName(playerid, n, 24);
format(save, 40, "/Acc/%s.txt",n);
dini_IntSet(save, "Bombas", Bomba[playerid]);
return 1;
}
Quando o jogador digita o comando /explodirbomba ele recebe a mensagem "Vocк se explodiu.", logo ele seria um homem-bomba e a bomba deve explodir sobre ele sem haver tempo de fuga
Mas caso queira que a bomba seja explodida apуs 10 segundos, por exemplo, use este codigo:
PHP код:
#include <Dini>
forward Explodir(Float:X, Float:Y, Float:Z, Float:Raio);
new Bomba[MAX_PLAYERS];
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/comprarbomba", cmdtext, true, 10) == 0)
{
if(GetPlayerMoney(playerid)<50000)return SendClientMessage(playerid, AZULCLARINHO,"{FF5959}| ERRO |{FFFFFF} Vocк Nгo Tem {FF5959}${FFFFFF}50000!");
SetPlayerAttachedObject(playerid,2,1654,1,0.1000,0.2000,0.0000,0.0,90.0000,180.0000);
GivePlayerMoney(playerid, -50000);
SendClientMessage(playerid, BRANCO,"{FF5959}| INFO |{FFFFFF} Vocк Comprou Uma Bomba!");
Bomba[playerid] ++;
return 1;
}
if(strcmp("/explodirbomba", cmdtext, true, 10) == 0)
{
if(Bomba[playerid] == 0) return SendClientMessage(playerid, BRANCO,"Vocк nгo comprou nenhuma bomba !");
Bomba[playerid] --;
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
SetTimerEx("Explodir", 10000, false, "fffd", x, y, z, 10);
SendClientMessage(playerid, BRANCO,"Corraa !! A bomba irб explodir em 10 segundos !");
return 1;
}
return 0;
}
public Explodir(Float:X, Float:Y, Float:Z, Float:Raio)
{
CreateExplosion(X, Y, Z, 11, Raio);
return 1;
}
public OnPlayerConnect(playerid)
{
new save[40], n[24];
GetPlayerName(playerid, n, 24);
format(save, 40, "/Acc/%s.txt",n);
if(fexist(save))
{
Bomba[playerid] = dini_Int(save, "Bombas");
}
else
{
dini_Create(save);
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new save[40], n[24];
GetPlayerName(playerid, n, 24);
format(save, 40, "/Acc/%s.txt",n);
dini_IntSet(save, "Bombas", Bomba[playerid]);
return 1;
}