I need help on a new command. -
flamur2012 - 16.07.2014
Could any one help me make a command looking like this one, but that would disarm some one like /zdisarm (ResetPlayerWeapons)
i need it to work for a specific class only as you can see on the code below thank you.
Код:
CMD:zheal(playerid,params[])
{
if(gettime() - 15 < Abilitys[playerid][HealCoolDown]) return GameTextForPlayer(playerid,"~w~ Cannot heal wait 15 seconds!",1000,5);
{
if(team[playerid] == TEAM_ZOMBIE)
{
if(pInfo[playerid][pZombieClass] == HZOMBIE)
{
new targetid,string[128],str[256];
if(sscanf(params,"u", targetid)) return SendClientMessage(playerid,-1,""chat" /zheal [playerid]");
new Float:hp;
GetPlayerHealth(targetid,hp);
if(team[targetid] == TEAM_ZOMBIE)
{
if(hp >= 80)
{
SendClientMessage(playerid,-1,""chat" That player already has enough health to survive");
}
else
{
if(pInfo[playerid][pZombieClass] == HZOMBIE)
{
SetPlayerHealth(targetid,hp+40);
format(string,sizeof(string),"~n~~n~~n~~n~~g~%s~w~ %s has healed you (New HP: %.2f)",GetClassName(playerid),PlayerName(playerid),hp);
GameTextForPlayer(targetid,string,3500,5);
format(str,sizeof(str),""chat""COL_LGREEN" %s %s has healed %s (NEW HP: %.2f HP)",GetClassName(playerid),PlayerName(playerid),PlayerName(targetid),hp,PlayerName(targetid));
SendClientMessageToAll(-1,str);
GivePlayerXP(playerid,20);
Abilitys[playerid][HealCoolDown] = gettime();
}
}
}
else return SendClientMessage(playerid,-1,""chat" You cannot heal an human!");
}
else return SendClientMessage(playerid,-1,""chat""COL_LGREEN" You'll need to be Zombie Medic!");
}
else return SendClientMessage(playerid,-1,""chat""COL_LGREEN" You'll need to be an zombie to use this command!");
}
return 1;
}
Re: I need help on a new command. -
flamur2012 - 16.07.2014
Anyone please?? i really need this
Re: I need help on a new command. -
Miguel - 16.07.2014
pawn Код:
CMD:zdisarm(playerid, params[])
{
new targetid, string[128], str[256];
if (team[playerid] != TEAM_ZOMBIE)
SendClientMessage(playerid,-1,""chat""COL_LGREEN" You'll need to be an zombie to use this command!");
else if (pInfo[playerid][pZombieClass] != HZOMBIE)
SendClientMessage(playerid,-1,""chat""COL_LGREEN" You'll need to be Zombie Medic!");
else if (sscanf(params, "u", targetid))
SendClientMessage(playerid,-1,""chat" /zdisarm [playerid]");
else if (team[targetid] != TEAM_ZOBIE)
SendClientMessage(playerid,-1,""chat" You cannot disarm a human!");
else
{
ResetPlayerWeapons(targetid);
format(string,sizeof(string),"~n~~n~~n~~n~~g~%s~w~ %s has disarmed you",GetClassName(playerid),PlayerName(playerid));
GameTextForPlayer(targetid,string,3500,5);
format(str,sizeof(str),""chat""COL_LGREEN" %s %s has disarmed %s",GetClassName(playerid),PlayerName(playerid),PlayerName(targetid),PlayerName(targetid));
SendClientMessageToAll(-1,str);
GivePlayerXP(playerid,20);
//Abilitys[playerid][HealCoolDown] = gettime();
}
return 1;
}
Re: I need help on a new command. -
flamur2012 - 16.07.2014
Thank you soo much. But i really need a cool down so i can use this option every 2 minutes
Re: I need help on a new command. -
Miguel - 16.07.2014
You're gonna have to add a new field to your ability enum and ask for it anywhere in the command, just like they did in the original command. You could even use a global variable...
pawn Код:
// Global var
new gDisarmCoolDown[MAX_PLAYERS] = {0, ...};
CMD:zdisarm(playerid, params[])
{
new targetid, string[128], str[256];
if (team[playerid] != TEAM_ZOMBIE)
SendClientMessage(playerid,-1,""chat""COL_LGREEN" You'll need to be an zombie to use this command!");
else if (gettime() - 15 < gDisarmCoolDown[playerid])
GameTextForPlayer(playerid,"~w~ Cannot disarm wait 15 seconds!",1000,5);
else if (pInfo[playerid][pZombieClass] != HZOMBIE)
SendClientMessage(playerid,-1,""chat""COL_LGREEN" You'll need to be Zombie Medic!");
else if (sscanf(params, "u", targetid))
SendClientMessage(playerid,-1,""chat" /zdisarm [playerid]");
else if (team[targetid] != TEAM_ZOBIE)
SendClientMessage(playerid,-1,""chat" You cannot disarm a human!");
else
{
ResetPlayerWeapons(targetid);
format(string,sizeof(string),"~n~~n~~n~~n~~g~%s~w~ %s has disarmed you",GetClassName(playerid),PlayerName(playerid));
GameTextForPlayer(targetid,string,3500,5);
format(str,sizeof(str),""chat""COL_LGREEN" %s %s has disarmed %s",GetClassName(playerid),PlayerName(playerid),PlayerName(targetid),PlayerName(targetid));
SendClientMessageToAll(-1,str);
GivePlayerXP(playerid,20);
gDisarmCoolDown[playerid] = gettime();
}
return 1;
}
Re: I need help on a new command. -
flamur2012 - 16.07.2014
OMG i dont know how to thank you. You are one heck of a helpful man <3