25.04.2009, 15:19
Hello... First the idea of this. Ok i have made a good bomb script (this is just a part of it..) But i wonted to make a auto Detonator for it But here I have a problem.. The player that plant the bomb shuld not be able to explode it when the player are near it... And it shuld work but my code works but when there are more then one player on the server the bomb planter get exploded...
Код:
public BombTimer2(playerid) { if(Bombauto[playerid] == 1) { if(BombArmed[playerid] == 1) { } else { new Float:XX; new Float:YY; new Float:ZZ; new Float:X; new Float:Y; new Float:Z; XX = BombX[playerid][2]; YY = BombY[playerid][2]; ZZ = BombZ[playerid][2]; X = BombX[playerid][1]; Y = BombY[playerid][1]; Z = BombZ[playerid][1]; for(new i = 0; i <= MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(PlayerToPoint(4.0, i, X, Y, Z)) { idd2 = i; // Why do this code return evry connected id? when it shuld be in the area? BombTimer3(playerid); } else { if(PlayerToPoint(4.0, i, XX, YY, ZZ)) { idd2 = i; // Why do this code return evry connected id? when it shuld be in the area? BombTimer3(playerid); } } } } } return 1; } public BombTimer3(playerid) { new tmp[256]; format(tmp, 256, " idd2= %d (ID: %d)", idd2, playerid); SendClientMessageToAll( COLOR_ADMIN_MESSAGE, tmp); if(BombArmed[playerid] == 1) { print("3"); } else { if (playerid == idd2) { print("4"); } else { print("5"); CreateExplosion(BombX[playerid][1], BombY[playerid][1], BombZ[playerid][1], 0, 5); CreateExplosion(BombX[playerid][2], BombY[playerid][2], BombZ[playerid][2], 0, 5); SendClientMessage(playerid, COLOR_GREY, "Bomb exploded!"); GetPlayerName(playerid, killst, MAX_PLAYER_NAME); DestroyObject(BombObject2[playerid]); DestroyObject(BombObject[playerid]); BombArmed[playerid] = 1; new Float:XX; new Float:YY; new Float:ZZ; new Float:X; new Float:Y; new Float:Z; XX = BombX[playerid][2]; YY = BombY[playerid][2]; ZZ = BombZ[playerid][2]; X = BombX[playerid][1]; Y = BombY[playerid][1]; Z = BombZ[playerid][1]; idd = playerid; for(new i=0;i<MAX_PLAYERS;i++) if(PlayerToPoint(40.0, i, X, Y, Z)) { killbomb[i] = 1; } for(new i=0;i<MAX_PLAYERS;i++) if(PlayerToPoint(40.0, i, XX, YY, ZZ)) { killbomb[i] = 1; } } } } } } return 1; }