public OnPlayerUpdate(playerid) { if(suPatlamaInmeCikma[playerid] == 1) { new Float:X, Float:Y, Float:Z; GetPlayerPos(playerid, X, Y, Z); if(IsPlayerInRangeOfPoint(playerid, 0.5, X, Y, 0.0)) { new killername[MAX_PLAYER_NAME], playername[MAX_PLAYER_NAME],string[256],killerid; //problem GetPlayerName(killerid, killername, sizeof(killername)); // problem GetPlayerName(playerid, playername, sizeof(playername)); // problem format(string, 250, "[Derby] Player: %s >> %s Water Cuts", killername,playername); // problem SendClientMessageToAll(-1,string); // problem ddSira--; katildim[playerid] = 0; suPatlamaInmeCikma[playerid] = 0; DestroyVehicle(ddAraba[playerid]); SetPVarInt(playerid,"katildi",0); SpawnPlayer(playerid); }} return 1; }
public OnPlayerUpdate(playerid) { if(suPatlamaInmeCikma[playerid] == 1) { new Float:X, Float:Y, Float:Z; GetPlayerPos(playerid, X, Y, Z); if(IsPlayerInRangeOfPoint(playerid, 0.5, X, Y, 0.0)) { new pName[MAX_PLAYER_NAME],string[128]; GetPlayerName(playerid, pName, MAX_PLAYER_NAME); new pID = GetClosestPlayer(playerid); if(pID == INVALID_PLAYER_ID) { format(string,128,"[Derby] Player: %s has fallen in the water.",pName); SendClientMessageToAll(-1,string); } else { new kName[MAX_PLAYER_NAME]; GetPlayerName(pID, kName, MAX_PLAYER_NAME); format(string, 128, "[Derby] Player: %s >> %s Water Cuts", pName,kName); SendClientMessageToAll(-1,string); } ddSira--; katildim[playerid] = 0; suPatlamaInmeCikma[playerid] = 0; DestroyVehicle(ddAraba[playerid]); SetPVarInt(playerid,"katildi",0); SpawnPlayer(playerid); } } return 1; } stock GetClosestPlayer(playerid) { new Float:p[3],i,Float:x,Float:t=70.0,tmp; GetPlayerPos(playerid,p[0],p[1],p[2]); for(; i<MAX_PLAYERS; i++) { if(!IsPlayerConnected(i)) continue; x = GetPlayerDistanceFromPoint(i,p[0],p[1],p[2]); if(x < t) t = x,tmp=i; } return (t==70.0)?INVALID_PLAYER_ID:tmp; }
So try it like this:
Code:
public OnPlayerUpdate(playerid) { if(suPatlamaInmeCikma[playerid] == 1) { new Float:X, Float:Y, Float:Z; GetPlayerPos(playerid, X, Y, Z); if(IsPlayerInRangeOfPoint(playerid, 0.5, X, Y, 0.0)) { new pName[MAX_PLAYER_NAME],string[128]; GetPlayerName(playerid, pName, MAX_PLAYER_NAME); new pID = GetClosestPlayer(playerid); if(pID == INVALID_PLAYER_ID) { format(string,128,"[Derby] Player: %s has fallen in the water.",pName); SendClientMessageToAll(-1,string); } else { new kName[MAX_PLAYER_NAME]; GetPlayerName(pID, kName, MAX_PLAYER_NAME); format(string, 128, "[Derby] Player: %s >> %s Water Cuts", pName,kName); SendClientMessageToAll(-1,string); } ddSira--; katildim[playerid] = 0; suPatlamaInmeCikma[playerid] = 0; DestroyVehicle(ddAraba[playerid]); SetPVarInt(playerid,"katildi",0); SpawnPlayer(playerid); } } return 1; } stock GetClosestPlayer(playerid) { new Float:p[3],i,Float:x,Float:t=70.0,tmp; GetPlayerPos(playerid,p[0],p[1],p[2]); for(; i<MAX_PLAYERS; i++) { if(!IsPlayerConnected(i)) continue; x = GetPlayerDistanceFromPoint(i,p[0],p[1],p[2]); if(x < t) t = x,tmp=i; } return (t==70.0)?INVALID_PLAYER_ID:tmp; } |
stock GetClosestPlayer(playerid) { new Float:p[3],i,Float:x,Float:t=70.0,tmp; GetPlayerPos(playerid,p[0],p[1],p[2]); for(; i<MAX_PLAYERS; i++) { if(!IsPlayerConnected(i) || i == playerid) continue; x = GetPlayerDistanceFromPoint(i,p[0],p[1],p[2]); if(x < t) t = x,tmp=i; } return (t==70.0)?INVALID_PLAYER_ID:tmp; }
Oh yeah i failed, write the function like this:
Code:
stock GetClosestPlayer(playerid) { new Float:p[3],i,Float:x,Float:t=70.0,tmp; GetPlayerPos(playerid,p[0],p[1],p[2]); for(; i<MAX_PLAYERS; i++) { if(!IsPlayerConnected(i) || i == playerid) continue; x = GetPlayerDistanceFromPoint(i,p[0],p[1],p[2]); if(x < t) t = x,tmp=i; } return (t==70.0)?INVALID_PLAYER_ID:tmp; } |