NoPressF
Умник
Привет всем написал функцию для пользователей этого форума.
Изменённая функция CreateExplosion. Думаю многим пользователям эта функция понадобится.
Изменённая функция CreateExplosion. Думаю многим пользователям эта функция понадобится.
- CreateExplosion(Float:x, Float:y, Float:z, type, Float:radius, Float:Strength = -1.0);
- Float:Strength - Сила взрыва. Тоесть установив силу взрыва 10.0 ближайшим игрокам попавшим под взрыв получит урон 10.0.
PHP:
stock Float:new_GetPlayerArmour(playerid)
{
new Float:PlayerArmour;
GetPlayerArmour(playerid, PlayerArmour);
return PlayerArmour;
}
stock new_CreateExplosion(Float:x, Float:y, Float:z, type, Float:Radius, Float:Strength = -1.0)
{
if(Strength == -1.0)
return CreateExplosion(x, y, z, type, Radius);
new
Float:PlayerHealthBeforeExplosion,
Float:PlayerArmourBeforeExplosion;
#if defined foreach
foreach(Player, i)
{
if(IsPlayerInRangeOfPoint(i, Radius, x, y, z))
{
if(!new_GetPlayerArmour(i))
{
GetPlayerHealth(i, PlayerHealthBeforeExplosion);
SetPlayerHealthGodmode(i);
}
else
{
GetPlayerArmour(i, PlayerArmourBeforeExplosion);
SetPlayerArmourGodmode(i);
}
}
}
CreateExplosion(x, y, z, type, Radius);
foreach(Player, i)
{
if(IsPlayerInRangeOfPoint(i, Radius, x, y, z))
{
if(!new_GetPlayerArmour(i))
SetPlayerHealth(i, PlayerHealthBeforeExplosion-Strength);
else
SetPlayerArmour(i, PlayerArmourBeforeExplosion-Strength);
}
}
#else
for(new i, j = GetPlayerPoolSize(); i <= j; i++)
{
if(!IsPlayerConnected(i))
continue;
if(IsPlayerInRangeOfPoint(i, Radius, x, y, z))
{
if(!new_GetPlayerArmour(i))
{
GetPlayerHealth(i, PlayerHealthBeforeExplosion);
SetPlayerHealthGodmode(i);
}
else
{
GetPlayerArmour(i, PlayerArmourBeforeExplosion);
SetPlayerArmourGodmode(i);
}
}
}
CreateExplosion(x, y, z, type, Radius);
for(new i, j = GetPlayerPoolSize(); i <= j; i++)
{
if(!IsPlayerConnected(i))
continue;
if(IsPlayerInRangeOfPoint(i, Radius, x, y, z))
{
if(!new_GetPlayerArmour(i))
SetPlayerHealth(i, PlayerHealthBeforeExplosion-Strength);
else
SetPlayerArmour(i, PlayerArmourBeforeExplosion-Strength);
}
}
#endif
return true;
}
stock SetPlayerHealthGodmode(playerid) return SetPlayerHealth(playerid, 0x7F800000);
stock SetPlayerArmourGodmode(playerid) return SetPlayerArmour(playerid, 0x7F800000);
#if defined _ALS_CreateExplosion
#undef CreateExplosion
#else
#define _ALS_CreateExplosion
#endif
#define CreateExplosion new_CreateExplosion
PHP:
// Пример
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/explosion", false))
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
CreateExplosion(x, y, z, 7, 25, /*Сила взрыва*/10.0);
}
return true;
}
// Пример с другим командным процессором
CMD:explosion(playerid)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
CreateExplosion(x, y, z, 7, 25, /*Сила взрыва*/10.0);
return true;
}
Последнее редактирование:
