Jump to content
  • 0

[GF/RP] Problema sellcar


Otiy

Question

Atunci cand un carjacker da sellcar nu ii da bani va rog ajutatima

[pawn]if(strcmp(cmd,"/sellcar",true)==0)

{

    if(IsPlayerConnected(playerid))

    {

        if(PlayerInfo[playerid][pJob] != 10)

{

    SendClientMessage(playerid,COLOR_GREY,"  You are not a Car Dealer !");

    return 1;

}

if(!IsPlayerInAnyVehicle(playerid))

{

    SendClientMessage(playerid,COLOR_GREY,"  You are not in a Car !");

    return 1;

}

if(IsAnOwnableCar(idcar))

{

    SendClientMessage(playerid,COLOR_GREY,"  Use /v sellto to sell you car to other person !");

    return 1;

}

tmp = strtok(cmdtext, idx);

if(!strlen(tmp))

{

SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sellcar [playerid/PartOfName] [price]");

return 1;

}

//giveplayerid = strval(tmp);

giveplayerid = ReturnUser(tmp);

tmp = strtok(cmdtext, idx);

if(!strlen(tmp))

{

SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sellcar [playerid/PartOfName] [price]");

return 1;

}

new money = strval(tmp);

if(money < 1 || money > 6000000) { SendClientMessage(playerid, COLOR_GREY, "  Price not below $1 or above &6000000 !"); return 1; }

if (IsPlayerConnected(giveplayerid))

{

    if(giveplayerid != INVALID_PLAYER_ID)

    {

        if (ProxDetectorS(8.0, playerid, giveplayerid))

{

    if(giveplayerid == playerid)

    {

        SendClientMessage(playerid, COLOR_GREY, "  Cant sell to yourself!");

        return 1;

    }

    if(CarCalls[giveplayerid] > 0)

    {

        SendClientMessage(playerid, COLOR_GREY, "  That player has already bought a car, has to use /callcar first !");

        return 1;

    }

    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));

GetPlayerName(playerid, sendername, sizeof(sendername));

    format(string, sizeof(string), "* You offerd %s to buy your Car for $%d .", giveplayer, money);

SendClientMessage(playerid, COLOR_LIGHTBLUE, string);

format(string, sizeof(string), "* Car Dealer %s wants to sell you his Car for $%d, (type /accept car) to buy.", sendername, money);

SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);

CarOffer[giveplayerid] = playerid;

CarPrice[giveplayerid] = money;

CarID[giveplayerid] = GetPlayerVehicleID(playerid);

}

else

{

    SendClientMessage(playerid, COLOR_GREY, "  That player is not near you !");

}

    }

}

else

{

    SendClientMessage(playerid, COLOR_GREY, "  Invalid ID/Name !");

    return 1;

}

    }

return 1;

}[/pawn]

acesta este codu sellcar

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

[pawn]if(strcmp(x_job,"car",true) == 0)

{

    if(CarOffer[playerid] < 999)

    {

        if(IsPlayerConnected(CarOffer[playerid]))

        {

            if(GetPlayerCash(playerid) > CarPrice[playerid])

            {

                if(IsPlayerInVehicle(CarOffer[playerid], CarID[playerid]))

                {

                GetPlayerName(CarOffer[playerid], giveplayer, sizeof(giveplayer));

GetPlayerName(playerid, sendername, sizeof(sendername));

                new points;

                PlayerInfo[CarOffer[playerid]][pCarSkill] ++;

                if(PlayerInfo[CarOffer[playerid]][pCarSkill] == 50)

{ SendClientMessage(CarOffer[playerid], COLOR_YELLOW, "* Your Car Dealer Skill is now Level 2, Players that buy Cars from you can call it more often."); }

else if(PlayerInfo[CarOffer[playerid]][pCarSkill] == 100)

{ SendClientMessage(CarOffer[playerid], COLOR_YELLOW, "* Your Car Dealer Skill is now Level 3, Players that buy Cars from you can call it more often."); }

else if(PlayerInfo[CarOffer[playerid]][pCarSkill] == 200)

{ SendClientMessage(CarOffer[playerid], COLOR_YELLOW, "* Your Car Dealer Skill is now Level 4, Players that buy Cars from you can call it more often."); }

else if(PlayerInfo[CarOffer[playerid]][pCarSkill] == 400)

{ SendClientMessage(CarOffer[playerid], COLOR_YELLOW, "* Your Car Dealer Skill is now Level 5, Players that buy Cars from you can call it more often."); }

new level = PlayerInfo[CarOffer[playerid]][pCarSkill];

if(level >= 0 && level <= 50) { points = 1; }

else if(level >= 51 && level <= 100) { points = 2; }

else if(level >= 101 && level <= 200) { points = 3; }

else if(level >= 201 && level <= 400) { points = 4; }

else if(level >= 401) { points = 4; }

                format(string, sizeof(string), "* You bought a Car for $%d, from Car Dealer %s. (You can use /callcar %d times)",CarPrice[playerid],giveplayer,points);

SendClientMessage(playerid, COLOR_WHITE, string);

format(string, sizeof(string), "* You sold your Car to %s for $%d, the player can use /callcar %d times.",sendername,CarPrice[playerid],points);

SendClientMessage(CarOffer[playerid], COLOR_WHITE, string);

PlayerInfo[CarOffer[playerid]][pPayCheck] += CarPrice[playerid] * 5;

GivePlayerCash(playerid, -CarPrice[playerid]);

RemovePlayerFromVehicle(CarOffer[playerid]);

CarCalls[playerid] = points;

        CarOffer[playerid] = 999;

CarPrice[playerid] = 0;

return 1;

}

else

{

    SendClientMessage(playerid, COLOR_GREY, "  The Car Dealer is not in the offerd Car !");

    return 1;

}

            }

else

{

    SendClientMessage(playerid, COLOR_GREY, "  You cant afford the Car !");

    return 1;

}

        }

        return 1;

    }

else

{

    SendClientMessage(playerid, COLOR_GREY, "  No-one offered to buy a Car !");

    return 1;

}

}[/pawn]

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.