19.03.2015, 06:00
count++ not working good
new MineCount = 0;
new MineCount = 0;
Код:
CMD:placemine(playerid,params[]) { new Float:MineX,Float:MineY,Float:MineZ; if(MinePlaced[playerid] == 1) return SendClientMessage(playerid,COLOR_INDIANRED,"You have already place a mine somewhere."); GetPlayerPos(playerid,MineX,MineY,MineZ); CreateObject(1252,MineX,MineY,MineZ-1,0.0, 0.0, 96.0); for(new i = 0; i < MAX_PLAYERS; i++) MineLabel[i] = CreatePlayer3DTextLabel(i,"MINE HERE",COLOR_INDIANRED, MineX, MineY, MineZ,20.0); MinePos[playerid][0] = MineX; MinePos[playerid][1] = MineY; MinePos[playerid][2] = MineZ; SendClientMessage(playerid,COLOR_PURPLE,"You have placed a mine."); SetTimerEx("MineTimer", 1000, true, "d", playerid); MinePlaced[playerid] = 1; return 1; }
Код:
forward MineTimer(playerid); public MineTimer(playerid) { new string[128]; for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerInRangeOfPoint(i, 10.0, MinePos[playerid][0], MinePos[playerid][1], MinePos[playerid][2])) { MineCount++; format(string,sizeof(string),"DANGER!\n %i",MineCount); UpdatePlayer3DTextLabelText(i,MineLabel[i], COLOR_RED,string); } else if(IsPlayerInRangeOfPoint(i, 2.0, MinePos[playerid][0], MinePos[playerid][1], MinePos[playerid][2])) { if(GetPlayerState(i) != PLAYER_STATE_WASTED) { if(MineCount == 10) { CreateExplosion(MinePos[i][0], MinePos[i][1], MinePos[i][2], 0, 10.0); SetPlayerHealth(i,0.0); SendClientMessage(i,COLOR_INDIANRED,"You got blown away by a land mine."); DestroyObject(1252); } } } else { MineCount = 0; format(string,sizeof(string),"MINE HERE\n %i",MineCount); UpdatePlayer3DTextLabelText(i,MineLabel[i], COLOR_INDIANRED, string); } return 1; }