19.08.2016, 10:56
Quote:
This is the code to check if the player is near you or not. - ( Explaination is in the code. Which is commented)
Код:
CMD:near(playerid, parmas[]) { new id, idName[MAX_PLAYER_NAME], String[128], String2[128]; GetPlayerName(id, idName, sizeof(idName)); //Getting the name of the id you are going to input. if(sscanf(parmas, "u", id)) return SendClientMessage(playerid, -1, "Usage - /near [id]"); // if id is missing, it will show player message to type in the id. if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, -1, "Player not connected!"); if(id == playerid) return SendClientMessage(playerid, -1, "You can not enter your own id!"); if(GetPlayerDistanceFromPlayer(playerid, id) < 10.0) // If the player is in reach of the player in 10 tiles then it will show the message below. { format(String, sizeof(String), "%s is near you!", idName); SendClientMessage(playerid, -1, String); } else // else it will show this. { format(String2, sizeof(String2), "%s is not near you!", idName); SendClientMessage(playerid, -1, String2); } return 1; } GetPlayerDistanceFromPlayer(playerid, targetid) < (Tiles distance) The target id in the above case was id or else it can be anything you want. ed- issuerid, damagedid, etc. Tiles distance can be anything you want. 5.0, 10.0, 20.0 etc. |
Код:
CMD:heal(playerid, params[]) { new healerName[MAX_PLAYER_NAME]; new Float:healedHealth; new id, idName[MAX_PLAYER_NAME], forHealer[128], forHealed[128]; if (playerid == id) { return SendClientMessage(playerid, COLOR_RED, "Error: you cannot heal your self"); } if (GetPlayerDistanceFromPlayer(playerid, id) < 10.0) { if (gTeam[playerid] == gTeam[id]) { GetPlayerHealth(id, healedHealth); if (healedHealth > 99.00) { return SendClientMessage(playerid, 0xF00000, "Player you want to heal hasalready max health"); } else { healedHealth = 100.00; GetPlayerName(playerid, healerName, sizeof(healerName)); format(forHealed, 128, "You are healed by %s",healerName); SendClientMessage(id, 0xF00000, forHealed); GetPlayerName(id, idName, sizeof(idName)); format(forHealer, 128, "You healed", idName); } } } return 1; }