11.08.2016, 12:35
Medic can heal players who are not nearby him
CMD:healplayer(playerid,params[]) { if(GetPlayerSkin(playerid) != 275) return SendClientMessage(playerid, -1, "You are not a medic"); new id,Float:x,Float:y,Float:z,Float:Health,string[200],string2[200],string3[200],name[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME]; if(sscanf(params,"u",id)) return SendClientMessage(playerid,-1,"USAGE: /heal [ID]"); else if(gTeam[playerid] != gTeam[id]) return SendClientMessage(playerid,-1,"Why would you heal your enemies?"); else if(id == playerid) return SendClientMessage(playerid,-1,"You can't heal yourself."); else if(medic[playerid] == 0) return SendClientMessage(playerid,-1,"You are not medic"); else { GetPlayerPos(id,x,y,z); if(!IsPlayerInRangeOfPoint(id,2.0,x,y,z)) return SendClientMessage(playerid,-1,"The player is too far away from you."); GetPlayerHealth(id,Health); if(Health == 100) return SendClientMessage(playerid,-1,"This player's health is too high."); SetPlayerHealth(id,100); F_GivePlayerMoney(playerid,1500); SetPlayerScore(playerid,GetPlayerScore(playerid) +2); GetPlayerName(playerid,name,sizeof(name)); GetPlayerName(id,name2,sizeof(name2)); format(string,sizeof(string),"%s (%d) healed you.",name,playerid); format(string2,sizeof(string2),"You have healed %s (%d).",name2,id); format(string3,sizeof(string3),"%s (%d) has healed %s (%d) and recieved 1500$.",name,playerid,name2,id); SendClientMessage(id,-1,string); SendClientMessage(playerid,-1,string2); SendClientMessageToAll(-1,string3); } return 1; }
new pClass[MAX_PLAYERS];
#define ASSAULT 0
#define MEDIC 1
#define SNIPER 2
#define CLOSERANGE 3
#define PYROMAN 4
#define SPYKILLER 5
OnDialogResponse...
//choosen assault...
pClass[playerid] = ASSAULT;
//ect
//On Commands..
//Medic command example
//blabla
if(pClass[playerid] != MEDIC) return NotMedic..
Код:
CMD:healplayer(playerid,params[]) { if(GetPlayerSkin(playerid) != 275) return SendClientMessage(playerid, -1, "You are not a medic"); new id,Float:x,Float:y,Float:z,Float:Health,string[200],string2[200],string3[200],name[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME]; if(sscanf(params,"u",id)) return SendClientMessage(playerid,-1,"USAGE: /heal [ID]"); else if(gTeam[playerid] != gTeam[id]) return SendClientMessage(playerid,-1,"Why would you heal your enemies?"); else if(id == playerid) return SendClientMessage(playerid,-1,"You can't heal yourself."); else if(medic[playerid] == 0) return SendClientMessage(playerid,-1,"You are not medic"); else { GetPlayerPos(id,x,y,z); if(!IsPlayerInRangeOfPoint(id,2.0,x,y,z)) return SendClientMessage(playerid,-1,"The player is too far away from you."); GetPlayerHealth(id,Health); if(Health == 100) return SendClientMessage(playerid,-1,"This player's health is too high."); SetPlayerHealth(id,100); F_GivePlayerMoney(playerid,1500); SetPlayerScore(playerid,GetPlayerScore(playerid) +2); GetPlayerName(playerid,name,sizeof(name)); GetPlayerName(id,name2,sizeof(name2)); format(string,sizeof(string),"%s (%d) healed you.",name,playerid); format(string2,sizeof(string2),"You have healed %s (%d).",name2,id); format(string3,sizeof(string3),"%s (%d) has healed %s (%d) and recieved 1500$.",name,playerid,name2,id); SendClientMessage(id,-1,string); SendClientMessage(playerid,-1,string2); SendClientMessageToAll(-1,string3); } return 1; } |
GetPlayerPos(id,x,y,z);
if(!IsPlayerInRangeOfPoint(id,2.0,x,y,z)) return SendClientMessage(playerid,-1,"The player is too far away from you.");
if(!IsPlayerInRangeOfPoint(playerid,2.0,x,y,z))
// global:
new gPlayer_CMDhealplayer[MAX_PLAYERS];
// OnPlayerConnect:
gPlayer_CMDhealplayer[playerid] = 0;
// command /healplayer:
if (gPlayer_CMDhealplayer[playerid] && gettime() < gPlayer_CMDhealplayer[playerid]) return ... // error
// if the command has been used before and the 2 minutes haven't been passed, return the error about every 2 minutes
// other checks..
// rest of code.. sending messages
gPlayer_CMDhealplayer[playerid] = gettime() + 120; // current time + 2 minutes
if(GetPlayerScore(playerid) < 50) return SendClientMessage(playerid,-1,"You must have at least 50 score to play in this class!"),ShowPlayerDialog(playerid,DIALOG_CLASS,DIALOG_STYLE_LIST,"Class selection:","{90FF19}Assault\n{90FF19}Medic{FFFFFF}(50 score required)\n{90FF19}Sniper{FFFFFF}(100 score required)\n{90FF19}Close range{FFFFFF}(300 score required)\n{90FF19}Pyroman{FFFFFF}(500 score required)\n{90FF19}Spy Killer{FFFFFF}(1000 score required)","Choose",""); { SendClientMessage(playerid, -1,"{FFD900}[CLASS]{17E3CB} You have selected your class as {E31717}Medic."); medic[playerid] = 1; SetPlayerSkin(playerid, 275); GivePlayerWeapon(playerid,4,1); GivePlayerWeapon(playerid,22,100); GivePlayerWeapon(playerid,42,100); }