Este foi o codigo mais rapido que eu consegui criar, com certeza haverгo erros e ainda nгo testei:
PHP код:
new Float:Bomba[3];
new Bomb[MAX_PLAYERS];
new bombinha;
forward ExplodirBomba();
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
new idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmdtext,"/homembomba",true) == 0)
{
ShowPlayerDialog(playerid, 20, DIALOG_STYLE_MSGBOX, "Escolha o tipo de BOMBA:", "Qual bomba vocк deseja ?", "CONTROLADA", "PROGRAMADA");
return 1;
}
return 0;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 20)
{
if(response == 1)
{
GivePlayerWeapon(playerid, 40, 1);
GetPlayerPos(playerid, Bomba[0],Bomba[1],Bomba[2]);
bombinha = CreateDynamicObject(1654,Bomba[0]+1,Bomba[1],Bomba[2]-0.8,0.0,0.0,0.0);
Bomb[playerid] = 1;
return 1;
}
else if(response == 0)
{
ShowPlayerDialog(playerid, 21, DIALOG_STYLE_INPUT, "TEMPO DE EXPLOSГO", "Digite o tempo que a bomba levarб para explodir (em segundos !!)\n\nLEMBRE-SE: EM SEGUNDOS !", "OK", "SAIR");
return 1;
}
}
if(dialogid == 21)
{
if(response == 1)
{
new tempo = strval(inputtext)*1000;
if(tempo > 1800000) return SendClientMessage(playerid, 0xF8FF3FFF, "O tempo nгo pode ser superior а 1800000 (30 minutos) ");
bombinha = CreateDynamicObject(1654,Bomba[0]+1,Bomba[1],Bomba[2]-0.8,0.0,0.0,0.0);
SetTimer("ExplodirBomba",tempo,false);
}
else if(response == 0) return SendClientMessage(playerid, 0xF8FF3FFF, "Operaзгo cancelada !");
}
return 1;
}
public ExplodirBomba()
{
DestroyDynamicObject(bombinha);
CreateExplosion( Bomba[0],Bomba[1],Bomba[2], 7,20.0);
CreateExplosion( Bomba[0]+2,Bomba[1]+2,Bomba[2]+2, 7,20.0);
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys == KEY_FIRE && Bomb[playerid] == 1)
{
DestroyDynamicObject(bombinha);
CreateExplosion( Bomba[0],Bomba[1],Bomba[2], 7,20.0);
CreateExplosion( Bomba[0]+2,Bomba[1]+2,Bomba[2]+2, 7,20.0);
SendClientMessage(playerid, 0xF8FF3FFF, "Bomba explodida !");
return 1;
}
return 1;
}
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}