Cancel hit command. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Cancel hit command. (
/showthread.php?tid=657689)
Cancel hit command. -
Thanks - 13.08.2018
Hello friends! I've created a command for cancel hit! but there are no problems but How To I can add If someone /hit someone and other player wanna type eg: /chit 1 but he is not own the hit they must send him a message example:
You don't own this hit to cancel the hit.
PHP код:
CMD:chit(playerid, params[])
{
new ID,string[170];
if(sscanf(params, "uds[50]", ID)) return SendClientMessage(playerid, -1, "{189381}USAGE: {FFFFFF}/chit [ID]");
if(IsPlayerConnected(ID))
{
if(Cancelhit[playerid] == 1)
{
format(string, sizeof(string), "{68FF00}[Hit Cancelled]: {FFFFFF}Player {0080FF}%s(%d) {FFFFFF}has {E33667}Cancelled {FFFFFF}the hit on {FFD700}%s(%d){FFFFFF}.",ReturnPlayerName(playerid), playerid,ReturnPlayerName(ID), ID);
SendClientMessageToAll(-1, string);
GameTextForPlayer(ID, "~n~~n~~Y~HIT ~G~CANCELLED", 6500, 5);
GameTextForPlayer(playerid, "~n~~n~~P~You ~R~Cancelled ~G~the ~Y~HIT", 7000, 5);
hit[playerid] = 0;
Cancelhit[playerid] = 0;
}
else
SendClientMessage(playerid, -1, "{FF0000}Error: {FFFFFF}That player is not connected OR None hit this player.");
}
return 1;
}
Re: Cancel hit command. -
jlalt - 13.08.2018
assign Cancelhit to -1 by default.
and assign it to targetid when /hit used. ex Cancelhit[playerid] = targetid;
then later
so
PHP код:
CMD:chit(playerid, params[])
{
new ID,string[170];
if(sscanf(params, "u", ID)) return SendClientMessage(playerid, -1, "{189381}USAGE: {FFFFFF}/chit [ID]");
if(IsPlayerConnected(ID))
{
if(Cancelhit[ID] == playerid)
{
format(string, sizeof(string), "{68FF00}[Hit Cancelled]: {FFFFFF}Player {0080FF}%s(%d) {FFFFFF}has {E33667}Cancelled {FFFFFF}the hit on {FFD700}%s(%d){FFFFFF}.",ReturnPlayerName(playerid), playerid,ReturnPlayerName(ID), ID);
SendClientMessageToAll(-1, string);
GameTextForPlayer(ID, "~n~~n~~Y~HIT ~G~CANCELLED", 6500, 5);
GameTextForPlayer(playerid, "~n~~n~~P~You ~R~Cancelled ~G~the ~Y~HIT", 7000, 5);
hit[playerid] = 0;
Cancelhit[ID] = -1;
}
else if(Cancelhit[ID] == -1)
SendClientMessage(playerid, -1, "{FF0000}Error: {FFFFFF}You don't own any hit from this player to cancel!");
else
SendClientMessage(playerid, -1, "{FF0000}Error: {FFFFFF}You don't own this player's hit to cancel!");
}
return 1;
}