This command still not working correct
#1

well this is the /v sell command, and the /accept vehicle. if i sell my car to someone they will get the vehicle. and they will see it on /v list. but they cant set its parkposition, because it says its not their vehicle.


/v sell
pawn Код:
if(strcmp(x_job,"sell",true) == 0)
            {
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_WHITE, ""COL_SZR"Usage:"COL_WHITE" /v sell [playerid/name] [price]");
                    return 1;
                }
                new idcar = GetPlayerVehicleID(playerid);
                GetPlayerName(playerid, sendername, sizeof(sendername));
                if(strcmp(sendername, CarInfo[VehicleOwned[idcar]][cOwner], true) != 0)
                {
                    SendClientMessage(playerid,COLOR_GREY,"This vehicle does not belong to you.");
                    return 1;
                }
                if(!CarInfo[VehicleOwned[idcar]][cOwner])
                {
                    SendClientMessage(playerid,COLOR_GREY,"This vehicle does not belong to you.");
                    return 1;
                }
                giveplayerid = ReturnUser(tmp);
                if(giveplayerid==playerid) {
                    SendClientMessage(playerid,COLOR_GRAD2,"You already own this vehicle.");
                    return 1;
                }
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_WHITE, ""COL_SZR"Usage:"COL_WHITE" /v sell [playerid/name] [price]");
                    return 1;
                }
                new price;
                price=strval(tmp);
                if(price<0||price>9000000) {
                    SendClientMessage(playerid,COLOR_GRAD2,"Price cannot be below 0, or above 9,000,000!");
                    return 1;
                }
                if(giveplayerid==INVALID_PLAYER_ID || !IsPlayerConnected(giveplayerid)) {
                    SendClientMessage(playerid,COLOR_GRAD2,"Invalid Player");
                    return 1;
                }
                if(!ProxDetectorS(8.0, playerid, giveplayerid)) {
                    SendClientMessage(playerid,COLOR_GRAD2,"That player is not here.");
                    return 1;
                }
                if(PlayerInfo[giveplayerid][pLevel]<3) {
                    SendClientMessage(playerid,COLOR_GRAD2,"This player must be atleast level 3!");
                    return 1;
                }
                if (!IsPlayerInAnyVehicle(playerid))
                {
                    SendClientMessage(playerid,COLOR_GREY," You must be inside your vehicle !");
                    return 1;
                }
                if(strcmp(sendername, CarInfo[VehicleOwned[idcar]][cOwner], true) != 0)
                {
                    SendClientMessage(playerid,COLOR_GRAD2,"This is not your vehicle!");
                    return 1;
                }
                if(CarInfo[VehicleOwned[idcar]][cDonate] == 1)
                {
                    SendClientMessage(playerid,COLOR_GREY," You cannot sell a donate vehicle !");
                    return 1;
                }
                TrySell[playerid][0]=giveplayerid;
                TrySell[playerid][1]=price;
                TrySell[playerid][2]=VehicleOwned[idcar];
                TrySell[giveplayerid][0]=playerid;
                TrySell[giveplayerid][1]=price;
                TrySell[giveplayerid][2]=VehicleOwned[idcar];
                format(string,sizeof(string),"%s has offered %s to sell their %s for $%d",Name(playerid),Name(giveplayerid),vehName[GetVehicleModel(GetPlayerVehicleID(playerid))-400],price);
                ProxDetector(30.0,playerid,string,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                format(tmp,sizeof(tmp),"* %s wants to sell you their car for %i$ (type /accept vehicle to accept)",Name(playerid),price);
                SendClientMessage(giveplayerid,COLOR_LIGHTBLUE,tmp);
                VehicleOffer[giveplayerid] = playerid;
                VehiclePrice[giveplayerid] = price;
                return 1;
            }

/accept vehicle
pawn Код:
else if(strcmp(x_job,"vehicle",true) == 0)
            {
                new buyername[MAX_PLAYER_NAME];
                if(TrySell[playerid][0]==SCRIPT_PLAYERS) {
                    SendClientMessage(playerid,COLOR_GRAD2,"No one has offered to sell you their car!");
                    return 1;
                }
                new cost=TrySell[playerid][1];
                if(GetMoney(playerid)<cost) {
                    SendClientMessage(playerid,COLOR_GRAD2,"You don't even have enough cash!");
                    return 1;
                }
                playaid=TrySell[playerid][0];
                if(TrySell[playaid][0]!=playerid) {
                    SendClientMessage(playerid,COLOR_GRAD2,"This player is offline or not trying to sell to you!");
                    return 1;
                }
                if(PlayerInfo[playerid][pCarkey]==SCRIPT_CARS) {
                    PlayerInfo[playerid][pCarkey]=TrySell[playerid][2];
                } else if(PlayerInfo[playerid][pCarkey2]==SCRIPT_CARS) {
                    PlayerInfo[playerid][pCarkey2]=TrySell[playerid][2];
                } else if(PlayerInfo[playerid][pCarkey3]==SCRIPT_CARS) {
                    PlayerInfo[playerid][pCarkey3]=TrySell[playerid][2];
                } else if(PlayerInfo[playerid][pCarkey4]==SCRIPT_CARS) {
                    PlayerInfo[playerid][pCarkey4]=TrySell[playerid][2];
                } else if(PlayerInfo[playerid][pCarkey5]==SCRIPT_CARS) {
                    PlayerInfo[playerid][pCarkey5]=TrySell[playerid][2];
                } else {
                    SendClientMessage(playerid,COLOR_GRAD2,"You already have 5 vehicles.");
                    return 1;
                }
                GetPlayerName(playerid,playername,sizeof(playername));
                strcpy(CarInfo[TrySell[playerid][2]][cOwner],playername,MAX_PLAYER_NAME);
                KillPlayerCarKey(playaid,TrySell[playerid][2]);
                GiveMoney(playaid,cost);
                GiveMoney(playerid,-cost);
                TrySell[playerid][0]=SCRIPT_PLAYERS;
                TrySell[playaid][0]=SCRIPT_PLAYERS;
                format(string,sizeof(string),"%s sold their vehicle to %s, for $%s",RemoveUnderScore(playaid),RemoveUnderScore(playerid), Comma(cost));
                ProxDetector(30.0,playerid,string,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                format(tmp,sizeof(tmp),"%s sells his car to %s for $%i, Car ID %i",buyername,playername,cost,TrySell[playerid][2]); //buyername isn't the buyers name, its the sellers
                PayLog(tmp);
                VehicleOffer[playerid] = 999;
                VehiclePrice[playerid] = 0;
                UpdateAccount(playerid);
                SaveCars();
                return 1;
            }
Reply


Messages In This Thread
This command still not working correct - by MayaEU - 30.06.2016, 15:35
Re: This command still not working correct - by DarkSkull - 01.07.2016, 02:39
Re: This command still not working correct - by MayaEU - 01.07.2016, 11:48

Forum Jump:


Users browsing this thread: 1 Guest(s)