#include <a_samp>
forward IfAutoKaputtTimer(playerid);
forward Float:GetDistanceBetweenPlayers(p1,p2);
#define COLOR_RED 0xE60000FF
#define COLOR_WHITE 0xFFFFFFFF
static bool:PlayerMessageMotorschaden[MAX_PLAYERS] = { false };
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Feuerwehr Script by Funsocke");
print("--------------------------------------\n");
SetTimer("IfAutoKaputtTimer", 1000, 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;
}
public OnPlayerDisconnect(playerid, reason)
{
PlayerMessageMotorschaden[playerid] = false;
return 1;
}
public OnPlayerPrivmsg(playerid, recieverid, text[])
{
return 1;
}
public Float:GetDistanceBetweenPlayers(p1,p2){
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
if (!IsPlayerConnected(p1) || !IsPlayerConnected(p2)){
return -1.00;
}
GetPlayerPos(p1,x1,y1,z1);
GetPlayerPos(p2,x2,y2,z2);
return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
public IfAutoKaputtTimer(playerid)
{
new Float:health;
new string[256];
new vehicleid = GetPlayerVehicleID(playerid);
if(IsPlayerInAnyVehicle(playerid))
{
GetVehicleHealth(vehicleid, health);
format(string, 256, "~n~~n~~n~~n~~n~~n~~g~Auto Schaden : ~w~%.0f",health);
GameTextForPlayer(playerid, string, 2000, 5);
}
new VID, Float:h_vid;
if(IsPlayerConnected(playerid) && IsPlayerInAnyVehicle(playerid))
{
VID = GetPlayerVehicleID(playerid);
GetVehicleHealth(VID, h_vid);
if(h_vid <= 185 && PlayerMessageMotorschaden[playerid] == false)
{
TogglePlayerControllable(playerid, 0);
SendClientMessage(playerid, 0xFF6900AA, "Dieses Fahrzeug hat nun einen Motorschaden. Rufe die /112");
PlayerMessageMotorschaden[playerid] = true;
SetVehicleHealth(vehicleid, 185.0);
SetPlayerHealth(playerid,100);
} }
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new sendername[MAX_PLAYER_NAME];
new cmd[256];
new idx;
new string[256];
cmd = strtok(cmdtext,idx);
if(strcmp(cmd, "/befrei", true) == 0)
{
new tmp[256];
new giveplayer[200];
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
new otherplayer = strval(tmp);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "[BENUTZUNG]: /befrei [SpielerID]");
return 1;
}
if(!IsPlayerConnected(otherplayer)) return SendClientMessage(playerid, COLOR_WHITE, "Falsche SpielerID !");
if(GetDistanceBetweenPlayers(playerid,otherplayer <= 5.0)
{
GetPlayerName(otherplayer, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
new Float:X;
new Float:Y;
new Float:Z;
GetPlayerPos(playerid,X,Y,Z);
SetPlayerPos(otherplayer,X,Y+1,Z);
format(string, sizeof(string), "Du hast %s gerettet!!.", giveplayer);
SendClientMessage(playerid,COLOR_WHITE, string);
SendClientMessage(otherplayer, COLOR_WHITE, "Du wurdest gerettet");
TogglePlayerControllable(playerid, 1);
}
else
{
SendClientMessage(playerid, COLOR_RED, "Der Spieler ist zu weit von dir entfernt !");
}
}
return 1;
}
if(strcmp(cmdtext, "/112", true) == 0 || strcmp(cmdtext, "/feuerwehr", true) == 0)
{
new pname[30], str[100];
GetPlayerName(playerid,pname,sizeof(pname));
format(str,sizeof(str), "%s braucht die Feuwehr!",pname);
SendClientMessageToAll(COLOR_RED,str);
return 1;
}
return 0;
}
Nimmt^^