Cancel hit command.
#1

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(playeridparams[])
{
    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(stringsizeof(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(-1string);
            
GameTextForPlayer(ID"~n~~n~~Y~HIT ~G~CANCELLED"65005);
            
GameTextForPlayer(playerid"~n~~n~~P~You ~R~Cancelled ~G~the ~Y~HIT"70005);
            
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;

Reply
#2

assign Cancelhit to -1 by default.
and assign it to targetid when /hit used. ex Cancelhit[playerid] = targetid;
then later
so
PHP код:
CMD:chit(playeridparams[]) 

    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(stringsizeof(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(-1string); 
            
GameTextForPlayer(ID"~n~~n~~Y~HIT ~G~CANCELLED"65005); 
            
GameTextForPlayer(playerid"~n~~n~~P~You ~R~Cancelled ~G~the ~Y~HIT"70005); 
            
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

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)