enum Baum
{
Float:nx,
Float:ny,
Float:nz,
Status,
};
enum BaumI
{
BaumID,
};
stock const BaumListe[][Baum] =
{
{2421.24170, -674.21820, 125.12865,0},
{2440.17627, -677.40643, 120.78878,0},
{440.33716, -652.97058, 121.08259,0},
{2440.33716, -652.97058, 121.08259,0},
{2420.04517, -645.01202, 124.21252,0},
{2451.55176, -668.04510, 118.45145,0},
{2454.93506, -642.32330, 118.42748,0},
{2435.50659, -637.18665, 120.96262,0},
{2435.50659, -637.18665, 120.96262,0},
{2432.34302, -620.91498, 120.90723,0},
{2445.24268, -628.57214, 118.42748,0}
};
for(new i;i<sizeof(BaumListe);i++)
{
BaumInfo[i][BaumID] = CreateDynamicObject(654,BaumListe[i][nx],BaumListe[i][ny],BaumListe[i][nz],0.0,0.0,0.0);
}
if(newkeys & KEY_FIRE)
{
if(PlayerInfo[playerid][pJob] != 202) return SendClientMessage(playerid,COLOR_ERRORTEXT,"Du hast nicht den Beruf Holzfäller");
new i = GetBaum(playerid);
if(!IsPlayerInRangeOfPoint(playerid, 5.0, BaumListe[i][nx],BaumListe[i][ny],BaumListe[i][nz])) return 1;
if(BaumListe[i][Status] != 0)return SendClientMessage(playerid,COLOR_ERRORTEXT,"Dieser Baum wächst gerade erst wieder!");
MoveDynamicObject(BaumInfo[i][BaumID], BaumListe[i][nx],BaumListe[i][ny],BaumListe[i][nz]-10,2.0,0,0,0);
BaumListe[i][Status] = 1;
GameTextForPlayer(playerid,"~r~Baum Faellt!",2000,3);
DestroyDynamicObject(BaumInfo[i][BaumID]);
}
stock GetBaum(playerid) {
new idx;
for(new i,Float:max=999.0,Float:tmp;i<sizeof(BaumListe);i++) {
tmp=GetPlayerDistanceFromPoint(playerid, BaumListe[i][nx],BaumListe[i][ny],BaumListe[i][nz]);
if(tmp < max) max=tmp,idx=i;
}
return idx;
}
Alles anzeigen