30.09.2010, 11:58
(
Last edited by false; 19/01/2011 at 02:31 AM.
)
Можно сделать примерно так...
pawn Code:
#include <a_samp>
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], tmp[256], idx;
cmd = strtok(cmdtext, idx);
tmp = strtok(cmdtext,idx);
if(strcmp(cmd, "/testgm", true) == 0)
{
if(!IsPlayerAdmin( playerid ))return SendClientMessage(playerid, 0xffffffff, "Вы не админ");
if(!strlen(tmp))return SendClientMessage(playerid, 0xffffffff, "Укажите id игрока");
if(!IsNumeric(tmp))return SendClientMessage(playerid, 0xffffffff, "Неверно указан id игрока");
new player = strval(tmp);
if(IsPlayerConnected(player) && player != INVALID_PLAYER_ID)
{
if(IsPlayerInAnyVehicle(player))
{
new vehicleid = GetPlayerVehicleID(playerid);
new Float:health, Float:X, Float:Y, Float:Z;
GetVehicleHealth(vehicleid, health);
SetPVarFloat(player, "VehicleHealth", health);
SetVehicleHealth(vehicleid, 1000);
GetPlayerPos(player,X,Y,Z);
CreateExplosion(X,Y,Z-6,8,0);
SetTimerEx("TestGmModeInVehicle",200,0, "i", player);
}
else
{
new Float:health, Float:X, Float:Y, Float:Z;
GetPlayerHealth(player, health);
SetPlayerHealth(player, 100);
SetPVarFloat(playerid, "PlayerHealth", health);
GetPlayerPos(player,X,Y,Z);
CreateExplosion(X,Y,Z-6,8,0);
SetTimerEx("TestGmModeOnFoot",200,0, "i", player);
}
}
return 1;
}
return 0;
}
forward TestGmModeOnFoot(playerid);
public TestGmModeOnFoot(playerid)
{
new Float:health;
GetPlayerHealth(playerid, health);
if(health < 100)
{
SendClientMessageToAll(0xffffffff,"Проверка пройдена ;)");
SetPlayerHealth(playerid, GetPVarFloat(playerid, "PlayerHealth"));
}
else
{
SendClientMessageToAll(0xffffffff,"чиииииитеееееер!!!!!!!!!!!!!");
SetPlayerHealth(playerid, GetPVarFloat(playerid, "PlayerHealth"));
}
return 1;
}
forward TestGmModeInVehicle(playerid);
public TestGmModeInVehicle(playerid)
{
new vehicleid = GetPlayerVehicleID(playerid);
new Float:health;
GetVehicleHealth(vehicleid, health);
if(health < 1000)
{
SendClientMessageToAll(0xffffffff,"Проверка пройдена ;)");
RepairVehicle(vehicleid);
}
else SendClientMessageToAll(0xffffffff,"чиииииитеееееер!!!!!!!!!!!!!");
return 1;
}
stock IsNumeric(string[])
{
for (new i = 0, j = strlen(string); i < j; i++)
if (string[i] > '9' || string[i] < '0') return 0;
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;
}