Selling a Car
#1

Hello!

I seem to be struggling with something.

We have VIP Cars and such and we're trying to prevent them from being sold in game. This is what i've came up with

pawn Код:
public IsAMAXerCar(vehicleid)
{
    new maxcar = GetVehicleModel(vehicleid);
    if(maxcar == 400 || maxcar == 404 || maxcar == 413 || maxcar == 418 || maxcar == 479 || maxcar == 482 || maxcar == 491 || maxcar == 518,
    maxcar == 543 || maxcar == 547 || maxcar == 554 || maxcar == 561 || maxcar == 600 || maxcar == 421 || maxcar == 422 || maxcar == 458,
    maxcar == 474 || maxcar == 483 || maxcar == 489 || maxcar == 500 || maxcar == 507 || maxcar == 516 || maxcar == 527 || maxcar == 533,
    maxcar == 549 || maxcar == 551 || maxcar == 402 || maxcar == 409 || maxcar == 424 || maxcar == 434 || maxcar == 445 || maxcar == 447,
    maxcar == 453 || maxcar == 463 || maxcar == 484 || maxcar == 545 || maxcar == 555 || maxcar == 595 || maxcar == 568 || maxcar == 519,
    maxcar == 423 || maxcar == 580)
    {
         return 0;
    }
    return 1;
}




if(strcmp(cmd, "/sellcar", true) == 0)
    {
        //if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle to use this command!");

        new ivID = GetPlayerVehicleID(playerid),
            Float:Pos[4];

        GetVehiclePos(ivID, Pos[0], Pos[1], Pos[2]);
        GetVehicleZAngle(ivID, Pos[3]);

        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            return SendClientMessage(playerid, COLOR_WHITE, "{00FF00}Usage:{FFFFFF} /sellcar <playerid/PartOfName> <price>");
        }
        giveplayerid = ReturnUser(tmp);
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            return SendClientMessage(playerid, COLOR_WHITE, "{00FF00}Usage:{FFFFFF} /sellcar <playerid/PartOfName> <price>");
        }
        moneys = strvalEx(tmp);
        if(moneys >= 1) {} else return 1;
        if(IsAMAXerCar(ivID)) return SendClientMessage(playerid,-1,"You may not sell MAXer vehicles.");
        if(OwnedVeh(ivID) != 0)
It still allows the sale of the vehicles, despite my efforts. Maybe i'm overlooking something. Any ideas?
Reply
#2

I've tried several ways.
No luck.
If I'm overlooking something, please let me know.
Reply
#3

pawn Код:
if(maxcar == 400 || maxcar == 404 || maxcar == 413 || maxcar == 418 || maxcar == 479 || maxcar == 482 || maxcar == 491 || maxcar == 518,
    maxcar == 543 || maxcar == 547 || maxcar == 554 || maxcar == 561 || maxcar == 600 || maxcar == 421 || maxcar == 422 || maxcar == 458,
    maxcar == 474 || maxcar == 483 || maxcar == 489 || maxcar == 500 || maxcar == 507 || maxcar == 516 || maxcar == 527 || maxcar == 533,
    maxcar == 549 || maxcar == 551 || maxcar == 402 || maxcar == 409 || maxcar == 424 || maxcar == 434 || maxcar == 445 || maxcar == 447,
    maxcar == 453 || maxcar == 463 || maxcar == 484 || maxcar == 545 || maxcar == 555 || maxcar == 595 || maxcar == 568 || maxcar == 519,
    maxcar == 423 || maxcar == 580)
Are these supposed to be allowed or not?
Reply
#4

Quote:
Originally Posted by FUNExtreme
Посмотреть сообщение
pawn Код:
if(maxcar == 400 || maxcar == 404 || maxcar == 413 || maxcar == 418 || maxcar == 479 || maxcar == 482 || maxcar == 491 || maxcar == 518,
    maxcar == 543 || maxcar == 547 || maxcar == 554 || maxcar == 561 || maxcar == 600 || maxcar == 421 || maxcar == 422 || maxcar == 458,
    maxcar == 474 || maxcar == 483 || maxcar == 489 || maxcar == 500 || maxcar == 507 || maxcar == 516 || maxcar == 527 || maxcar == 533,
    maxcar == 549 || maxcar == 551 || maxcar == 402 || maxcar == 409 || maxcar == 424 || maxcar == 434 || maxcar == 445 || maxcar == 447,
    maxcar == 453 || maxcar == 463 || maxcar == 484 || maxcar == 545 || maxcar == 555 || maxcar == 595 || maxcar == 568 || maxcar == 519,
    maxcar == 423 || maxcar == 580)
Are these supposed to be allowed or not?
Not allowed to be sold
Reply
#5

Quote:
Originally Posted by FUNExtreme
Посмотреть сообщение
pawn Код:
if(maxcar == 400 || maxcar == 404 || maxcar == 413 || maxcar == 418 || maxcar == 479 || maxcar == 482 || maxcar == 491 || maxcar == 518,
    maxcar == 543 || maxcar == 547 || maxcar == 554 || maxcar == 561 || maxcar == 600 || maxcar == 421 || maxcar == 422 || maxcar == 458,
    maxcar == 474 || maxcar == 483 || maxcar == 489 || maxcar == 500 || maxcar == 507 || maxcar == 516 || maxcar == 527 || maxcar == 533,
    maxcar == 549 || maxcar == 551 || maxcar == 402 || maxcar == 409 || maxcar == 424 || maxcar == 434 || maxcar == 445 || maxcar == 447,
    maxcar == 453 || maxcar == 463 || maxcar == 484 || maxcar == 545 || maxcar == 555 || maxcar == 595 || maxcar == 568 || maxcar == 519,
    maxcar == 423 || maxcar == 580)
Are these supposed to be allowed or not?
Am I misunderstanding what you're asking? These are the ones that are denied
Reply
#6

If you doing so to don't allowed these models change return 0 to 1 AND 1 to 0 in your IsAMAXerCar() function. AS currently you are returning false if these model are and on CMD you are checking for these model which return false if model are from the list.
Reply
#7

Quote:
Originally Posted by Shabi RoxX
Посмотреть сообщение
If you doing so to don't allowed these models change return 0 to 1 AND 1 to 0 in your IsAMAXerCar() function. AS currently you are returning false if these model are and on CMD you are checking for these model which return false if model are from the list.
Yeah, also..

Quote:
Originally Posted by DJ_Shocker
Посмотреть сообщение
Hello!

I seem to be struggling with something.

We have VIP Cars and such and we're trying to prevent them from being sold in game. This is what i've came up with

pawn Код:
public IsAMAXerCar(vehicleid)
{
    new maxcar = GetVehicleModel(vehicleid);
    if(maxcar == 400 || maxcar == 404 || maxcar == 413 || maxcar == 418 || maxcar == 479 || maxcar == 482 || maxcar == 491 || maxcar == 518,
    maxcar == 543 || maxcar == 547 || maxcar == 554 || maxcar == 561 || maxcar == 600 || maxcar == 421 || maxcar == 422 || maxcar == 458,
    maxcar == 474 || maxcar == 483 || maxcar == 489 || maxcar == 500 || maxcar == 507 || maxcar == 516 || maxcar == 527 || maxcar == 533,
    maxcar == 549 || maxcar == 551 || maxcar == 402 || maxcar == 409 || maxcar == 424 || maxcar == 434 || maxcar == 445 || maxcar == 447,
    maxcar == 453 || maxcar == 463 || maxcar == 484 || maxcar == 545 || maxcar == 555 || maxcar == 595 || maxcar == 568 || maxcar == 519,
    maxcar == 423 || maxcar == 580)
    {
         return 0;
    }
    return 1;
}




if(strcmp(cmd, "/sellcar", true) == 0)
    {
        //if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle to use this command!");

        new ivID = GetPlayerVehicleID(playerid),
            Float:Pos[4];

        GetVehiclePos(ivID, Pos[0], Pos[1], Pos[2]);
        GetVehicleZAngle(ivID, Pos[3]);

        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            return SendClientMessage(playerid, COLOR_WHITE, "{00FF00}Usage:{FFFFFF} /sellcar <playerid/PartOfName> <price>");
        }
        giveplayerid = ReturnUser(tmp);
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            return SendClientMessage(playerid, COLOR_WHITE, "{00FF00}Usage:{FFFFFF} /sellcar <playerid/PartOfName> <price>");
        }
        moneys = strvalEx(tmp);
        if(moneys >= 1) {} else return 1;
        if(IsAMAXerCar(ivID)) return SendClientMessage(playerid,-1,"You may not sell MAXer vehicles.");
        if(OwnedVeh(ivID) != 0)
//You are missing a closing bracket here along with return 1;
It still allows the sale of the vehicles, despite my efforts. Maybe i'm overlooking something. Any ideas?
You are missing a closing bracket at the bottom of your /sellcar command along with "return 1;"
Unless you've missed it out while copying and pasting which I gather may has happened otherwise you will get shit loads of errors on compile.
Reply
#8

Quote:
Originally Posted by AphexCCFC
Посмотреть сообщение
Yeah, also..



You are missing a closing bracket at the bottom of your /sellcar command along with "return 1;"
Unless you've missed it out while copying and pasting which I gather may has happened otherwise you will get shit loads of errors on compile.
No this isn't copy and pasted, lol I promise you that. But yes I didn't notice the closing bracket. I'm not getting errors or warnings at all
Reply
#9

No I meant you may have missed it out when copying and pasting the code from your pawno to the forums haha.
You mean you don't have that last bracket added? The code should work after Shabi's suggestion and if you haven't added that last bracket here it is:

pawn Код:
if(strcmp(cmd, "/sellcar", true) == 0)
{
        //if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle to use this command!");

        new ivID = GetPlayerVehicleID(playerid),
            Float:Pos[4];

        GetVehiclePos(ivID, Pos[0], Pos[1], Pos[2]);
        GetVehicleZAngle(ivID, Pos[3]);

        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            return SendClientMessage(playerid, COLOR_WHITE, "{00FF00}Usage:{FFFFFF} /sellcar <playerid/PartOfName> <price>");
        }
        giveplayerid = ReturnUser(tmp);
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            return SendClientMessage(playerid, COLOR_WHITE, "{00FF00}Usage:{FFFFFF} /sellcar <playerid/PartOfName> <price>");
        }
        moneys = strvalEx(tmp);
        if(moneys >= 1) {} else return 1;
        if(IsAMAXerCar(ivID)) return SendClientMessage(playerid,-1,"You may not sell MAXer vehicles.");
        if(OwnedVeh(ivID) != 0)
        return 1;
}
Reply
#10

Ohhhhhhh I only pasted the necessary part of the /sellcar command.
And after I added the suggestion.

LIKE THIS:
pawn Код:
public IsAMAXerCar(vehicleid)
{
    new maxcar = GetVehicleModel(vehicleid);
    if(maxcar == 400 || maxcar == 404 || maxcar == 413 || maxcar == 418 || maxcar == 479 || maxcar == 482 || maxcar == 491 || maxcar == 518,
    maxcar == 543 || maxcar == 547 || maxcar == 554 || maxcar == 561 || maxcar == 600 || maxcar == 421 || maxcar == 422 || maxcar == 458,
    maxcar == 474 || maxcar == 483 || maxcar == 489 || maxcar == 500 || maxcar == 507 || maxcar == 516 || maxcar == 527 || maxcar == 533,
    maxcar == 549 || maxcar == 551 || maxcar == 402 || maxcar == 409 || maxcar == 424 || maxcar == 434 || maxcar == 445 || maxcar == 447,
    maxcar == 453 || maxcar == 463 || maxcar == 484 || maxcar == 545 || maxcar == 555 || maxcar == 595 || maxcar == 568 || maxcar == 519,
    maxcar == 423 || maxcar == 580)
    {
         return 1;
    }
    return 0;
}
It's still allowing the sales of the VIP Vehicles.

ENTIRE /sellcar COMMAND
pawn Код:
if(strcmp(cmd, "/sellcar", true) == 0)
    {
        //if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle to use this command!");

        new
            ivID = GetPlayerVehicleID(playerid),
            Float:Pos[4];

        GetVehiclePos(ivID, Pos[0], Pos[1], Pos[2]);
        GetVehicleZAngle(ivID, Pos[3]);

        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            return SendClientMessage(playerid, COLOR_WHITE, "{00FF00}Usage:{FFFFFF} /sellcar <playerid/PartOfName> <price>");
        }
        giveplayerid = ReturnUser(tmp);
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            return SendClientMessage(playerid, COLOR_WHITE, "{00FF00}Usage:{FFFFFF} /sellcar <playerid/PartOfName> <price>");
        }
        moneys = strvalEx(tmp);
        if(moneys >= 1) {} else return 1;
        if(IsAMAXerCar(ivID)) return SendClientMessage(playerid,-1,"You may not sell MAXer vehicles.");
        if(OwnedVeh(ivID) != 0)
        {
            if(strmatch(vInfo[OwnedVeh(ivID)][vOwner], pName(playerid)))
            {
                new sendernamen[MAX_PLAYER_NAME];
                GetPlayerName(giveplayerid, sendernamen, sizeof(sendernamen));
                /*new car1=0, car2=0, car3=0, carnr = 0;
                for(new i=0; i<MAX_VEHICLES; i++)
                {
                    if(strmatch(vInfo[OwnedVeh(i)][vOwner], sendernamen))
                    {
                        if(car1 == 0) { car1 = i; carnr ++; continue; }
                        else if(car2 == 0) { car2 = i; carnr ++; continue; }
                        else if(car3 == 0) { car3 = i; carnr ++; continue; }
                    }
                }
                if(PlayerInfo[giveplayerid][pAdmin] < 1)
                {
                    if(GetVehicleType(ivID) == 1 && GetVehicleType(car1) == 1 || GetVehicleType(ivID) == 1 && GetVehicleType(car2) == 1 || GetVehicleType(ivID) == 1 && GetVehicleType(car3) == 1) return SendClientMessage(playerid, COLOR_WHITE, "{DC0C0C}Car: {FFFFFF}That player already has a car!");

                    if(GetVehicleType(ivID) == 2 && GetVehicleType(car1) == 2 || GetVehicleType(ivID) == 2 && GetVehicleType(car2) == 2 || GetVehicleType(ivID) == 2 && GetVehicleType(car3) == 2 || GetVehicleType(ivID) == 3 && GetVehicleType(car1) == 3 || GetVehicleType(ivID) == 3 && GetVehicleType(car2) == 3
                    || GetVehicleType(ivID) == 3 && GetVehicleType(car3) == 3) return SendClientMessage(playerid, COLOR_WHITE, "{DC0C0C}Bike: {FFFFFF}That player already has a bike!");

                    if(GetVehicleType(ivID) == 4 && GetVehicleType(car1) == 4 || GetVehicleType(ivID) == 4 && GetVehicleType(car2) == 4 || GetVehicleType(ivID) == 4 && GetVehicleType(car3) == 4 || GetVehicleType(ivID) == 5 && GetVehicleType(car1) == 5 || GetVehicleType(ivID) == 5 && GetVehicleType(car2) == 5
                    || GetVehicleType(ivID) == 5 && GetVehicleType(car3) == 5 || GetVehicleType(ivID) == 9 && GetVehicleType(car1) == 9 || GetVehicleType(ivID) == 9 && GetVehicleType(car2) == 9 || GetVehicleType(ivID) == 9 && GetVehicleType(car3) == 9) return SendClientMessage(playerid, COLOR_WHITE, "{DC0C0C}Vehicle: {FFFFFF}That player already has a boat / plane!");
                }

                if(PlayerInfo[giveplayerid][pCar1] != 0 && PlayerInfo[giveplayerid][pCar2] != 0 && PlayerInfo[giveplayerid][pCar3] != 0) return SendClientMessage(playerid, COLOR_WHITE, "{DC0C0C}That player already has 3 cars!");*/

                if(PlayerInfo[playerid][pLevel] >= 3) {} else return SendClientMessage(playerid, COLOR_WHITE, "{DC0C0C}Masina: {FFFFFF}You need level 3 to sell a vehicle!");
                new sendername1[MAX_PLAYERS];
                GetPlayerName(giveplayerid, sendername1, sizeof(sendername1));
                GetPlayerName(playerid, sendername, sizeof(sendername));
                OwnableCarOffer[giveplayerid] = playerid;
                OwnableCarID[giveplayerid] = GetPlayerVehicleID(playerid);
                OwnableCarPrice[giveplayerid] = moneys;
                format(string, sizeof(string), "{DC0C0C}Personal Vehicle: {FFFFFF}%s wants to sell their vehicle for $%d. Type /accept vehicle to accept.", sendername, moneys);
                SendClientMessage(giveplayerid, COLOR_WHITE, string);
                format(string, sizeof(string), "{DC0C0C}Personal Vehicle: {FFFFFF}You asked %s to buy your car for $%d.", sendername1, moneys);
                SendClientMessage(playerid, COLOR_WHITE, string);
                return 1;
            }
            else return SendClientMessage(playerid, COLOR_RED, "{DC0C0C}Personal Vehicle: {FFFFFF}You don't own this vehicle!");
        }
        else return SendClientMessage(playerid, COLOR_RED, "{DC0C0C}Personal Vehicle: {FFFFFF}You can't sell this vehicle..");
    }
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)