SA-MP Forums Archive
Help [repair] - 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: Help [repair] (/showthread.php?tid=541575)



Help [repair] - KingPersona - 12.10.2014

Hello

i want make this cmd repair , when he try to repair herself can't..
+rep for help.

pawn Код:
CMD:repair(playerid,params[])
{
        new userID;
        new giveplayer[MAX_PLAYER_NAME];
        new sendername[MAX_PLAYER_NAME];
        new moneys, string[256];
        if(IsPlayerConnected(playerid))
        {
            if(playerVariables[playerid][pJob] != 3)
            {
                SendClientMessage(playerid, COLOR_GREY, "You are not a mechanic.");
                return 1;
            }
            if(sscanf(params, "ui", userID, moneys))
            {
                return SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/repair [playerid] [money]");
            }
            if(moneys < 1 || moneys > 15000) { SendClientMessage(playerid, COLOR_GREY, "The money must be until 15000$."); return 1; }
            if(IsPlayerConnected(userID))
            {
                if(userID != INVALID_PLAYER_ID)
                {
                    if(IsPlayerInAnyVehicle(userID))
                    {
                        GetPlayerName(userID, giveplayer, sizeof(giveplayer));
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        format(string, sizeof(string), "You offerd %s to fix his car for $%d.",giveplayer,moneys);
                        SendClientMessage(playerid, COLOR_WHITE, string);
                        format(string, sizeof(string), " Car Mechanic %s wants to repair your car for $%d,(type /accept repair to accept).",sendername,moneys);
                        SendClientMessage(userID, COLOR_WHITE, string);
                        RepairOffer[userID] = playerid;
                        RepairPrice[userID] = moneys;
                    }
                }
            }
        }
        return 1;
}
Thanks.


Re: Help [repair] - Chenko - 12.10.2014

Just add this somewhere in the command after you extract the params.

pawn Код:
if(userID == playerid)
     return SendClientMessage(playerid, COLOR_GREY, "You can't repair yourself.");



Re: Help [repair] - Berzerk - 12.10.2014

Just add this line above the money check:
if(userID == playerid) return SendClientMessage(playerid, COLOR_GREY, "You can't repair your own can.");


Re: Help [repair] - KingPersona - 12.10.2014

Quote:
Originally Posted by Chenko
Посмотреть сообщение
Just add this somewhere in the command after you extract the params.

pawn Код:
if(userID == playerid)
     return SendClientMessage(playerid, COLOR_GREY, "You can't repair yourself.");
thanks for answer bro,and help.

Like it ?
pawn Код:
CMD:repair(playerid,params[])
{
        new userID;
        new giveplayer[MAX_PLAYER_NAME];
        new sendername[MAX_PLAYER_NAME];
        new moneys, string[256];
        if(IsPlayerConnected(playerid))
        {
            if(playerVariables[playerid][pJob] != 3)
            {
                SendClientMessage(playerid, COLOR_GREY, "You are not a mechanic.");
                return 1;
            }
            if(sscanf(params, "ui", userID, moneys))
            {
                return SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/repair [playerid] [money]");
            }
            if(userID == playerid)
            return SendClientMessage(playerid, COLOR_GREY, "You can't repair yourself.");
            if(moneys < 1 || moneys > 15000) { SendClientMessage(playerid, COLOR_GREY, "The money must be until 15000$."); return 1; }
            if(IsPlayerConnected(userID))
            {
                if(userID != INVALID_PLAYER_ID)
                {
                    if(IsPlayerInAnyVehicle(userID))
                    {
                        GetPlayerName(userID, giveplayer, sizeof(giveplayer));
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        format(string, sizeof(string), "You offerd %s to fix his car for $%d.",giveplayer,moneys);
                        SendClientMessage(playerid, COLOR_WHITE, string);
                        format(string, sizeof(string), " Car Mechanic %s wants to repair your car for $%d,(type /accept repair to accept).",sendername,moneys);
                        SendClientMessage(userID, COLOR_WHITE, string);
                        RepairOffer[userID] = playerid;
                        RepairPrice[userID] = moneys;
                    }
                }
            }
        }
        return 1;
}
Quote:
Originally Posted by Berzerk
Посмотреть сообщение
Just add this line above the money check:
if(userID == playerid) return SendClientMessage(playerid, COLOR_GREY, "You can't repair your own can.");
u are funny =)))))


Re: Help [repair] - Chenko - 12.10.2014

Yes, just hit tab on the line with the "return SendClientMessage(playerid, COLOR_GREY, "You can't repair yourself.")"

Glad I could help you!


Re: Help [repair] - Berzerk - 12.10.2014

Put it in the same line, not under it.


Re: Help [repair] - KingPersona - 12.10.2014

Quote:
Originally Posted by Chenko
Посмотреть сообщение
Yes, just hit tab on the line with the "return SendClientMessage(playerid, COLOR_GREY, "You can't repair yourself.")"

Glad I could help you!
Thanks Bro , +rep.


Re: Help [repair] - Berzerk - 13.10.2014

Quote:
Originally Posted by Berzerk
Посмотреть сообщение
Just add this line above the money check:
if(userID == playerid) return SendClientMessage(playerid, COLOR_GREY, "You can't repair your own can.");
Car* xD