Impound Help
#1

Hello could someone help me. Everytime i stand next to a Ownable vehicle and type /impound 10000
it says you hav e to be close to a ownable vehicle and i know the vehicle is ownable and its owned.


PHP код:
if(strcmp(cmd"/impound"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            if(
PlayerInfo[playerid][pMember] != 1)
                return 
SendClientMessage(playeridCOLOR_GREY"You have to be a Cop!");
            if(
PlayerInfo[playerid][pRank] < 3)
                return 
SendClientMessage(playeridCOLOR_GREY"You have to be Rank 3!");
            if(
PlayerInfo[playerid][pOnDuty] == 0)
                return 
SendClientMessage(playeridCOLOR_GREY"You have to be on duty!");
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp))
                return 
SendClientMessage(playeridCOLOR_WHITE"USAGE: /impound [price]");
            new 
price strval(tmp);
            if(
price 10000)
                return 
SendClientMessage(playeridCOLOR_GREY"Maximum impound price is $10.000");
            if(
price 30000)
                return 
SendClientMessage(playeridCOLOR_GREY"Maximum impound price is $30.000");
            if(!
IsPlayerInRangeOfPoint(playerid40.02582.64, -2166.93, -0.22))
                return 
SendClientMessage(playeridCOLOR_GREY"You have to be in the Impound Parking Lot!");
            for(new 
1sizeof(CarInfo); i++)
            {
                new 
Float:XFloat:YFloat:Z;
                new 
Float:A;
                
GetVehiclePos(CarPickup[i], XYZ);
                if(
IsPlayerInRangeOfPoint(playerid2.0XYZ))
                {
                    if(
CarInfo[i][cOwned] == 1)
                    {
                        if(
CarInfo[i][Imp] == 1)
                            return 
SendClientMessage(playeridCOLOR_GREY"This vehicle is already impounded!");
                        
/*new owner[128];
                        strmid(owner, CarInfo[i][cOwner], 0, strlen(CarInfo[i][cOwner]), 255);
                        new player = ReturnUser(owner);
                        if(player != INVALID_PLAYER_ID)
                        {
                            SetPlayerCheckpoint(player, X, Y, Z, 5.0);
                            SendClientMessage(player, COLOR_WHITE, "["CB"SMS Inbox"CW"] "CB" Sender:"CW" Impound Service™ (4192)");
                            SendClientMessage(player, COLOR_WHITE, ""CB"Message:"CW" Your vehicle has been impounded!");
                        }*/
                        
CarInfo[i][cLocationx] = X;
                        
CarInfo[i][cLocationy] = Y;
                        
CarInfo[i][cLocationz] = Z;
                        
GetVehicleZAngle(iA);
                        
CarInfo[i][cAngle] = A;
                        
CarInfo[i][ImpPrice] = price;
                        
CarInfo[i][Imp] = 1;
                        
SaveVehicleComponents(i);
                        
OnPropUpdate(3i);
                        
DestroyVehicle(CarPickup[i]);
                        
CarPickup[i] = CreateVehicle(CarInfo[i][cModel],CarInfo[i][cLocationx],CarInfo[i][cLocationy],CarInfo[i][cLocationz],CarInfo[i][cAngle],CarInfo[i][cColorOne],CarInfo[i][cColorTwo],60000);
                        
SetVehicleModifications(i);
                        
ChangeVehiclePaintjob(iCarInfo[i][cPaintjob]);
                        
SendClientMessage(playeridCOLOR_YELLOW"Vehicle Impounded");
                        return 
1;
                    }
                    else
                        return 
SendClientMessage(playeridCOLOR_GREY"You can't impound vehicle's that is not owned!");
                }
                else
                    return 
SendClientMessage(playeridCOLOR_GREY"You have to be close to a ownable vehicle!");
            }
        }
        return 
1;
    } 
Reply
#2

By using return you end the loop, meaning that it checks the first car, and then finished. Try this:

Код:
if(strcmp(cmd, "/impound", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pMember] != 1)
                return SendClientMessage(playerid, COLOR_GREY, "You have to be a Cop!");
            if(PlayerInfo[playerid][pRank] < 3)
                return SendClientMessage(playerid, COLOR_GREY, "You have to be Rank 3!");
            if(PlayerInfo[playerid][pOnDuty] == 0)
                return SendClientMessage(playerid, COLOR_GREY, "You have to be on duty!");

            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
                return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /impound [price]");

            new price = strval(tmp);

            if(price < 10000)
                return SendClientMessage(playerid, COLOR_GREY, "Maximum impound price is $10.000");
            if(price > 30000)
                return SendClientMessage(playerid, COLOR_GREY, "Maximum impound price is $30.000");

            if(!IsPlayerInRangeOfPoint(playerid, 40.0, 2582.64, -2166.93, -0.22))
                return SendClientMessage(playerid, COLOR_GREY, "You have to be in the Impound Parking Lot!");

            new FoundCar = 0; //In it's current form, we have not yet found a vehicle
            for(new i = 1; i < sizeof(CarInfo); i++)
            {
                if(FoundCar == 0) //Saved running the rest of the code if we have already found a vehicle
                {
	                new Float:X, Float:Y, Float:Z;
	                new Float:A;
	                GetVehiclePos(CarPickup[i], X, Y, Z);
	                if(IsPlayerInRangeOfPoint(playerid, 2.0, X, Y, Z))
	                {
	                    if(CarInfo[i][cOwned] == 1)
	                    {
	                        if(CarInfo[i][Imp] == 1)
	                            return SendClientMessage(playerid, COLOR_GREY, "This vehicle is already impounded!");

	                        /*new owner[128];
	                        strmid(owner, CarInfo[i][cOwner], 0, strlen(CarInfo[i][cOwner]), 255);
	                        new player = ReturnUser(owner);
	                        if(player != INVALID_PLAYER_ID)
	                        {
	                            SetPlayerCheckpoint(player, X, Y, Z, 5.0);
	                            SendClientMessage(player, COLOR_WHITE, "["CB"SMS Inbox"CW"] "CB" Sender:"CW" Impound Service™ (4192)");
	                            SendClientMessage(player, COLOR_WHITE, ""CB"Message:"CW" Your vehicle has been impounded!");
	                        }*/
	                        FoundCar = 1; //Tells the scipt you have found the relevant vehicle
	                        CarInfo[i][cLocationx] = X;
	                        CarInfo[i][cLocationy] = Y;
	                        CarInfo[i][cLocationz] = Z;
	                        GetVehicleZAngle(i, A);
	                        CarInfo[i][cAngle] = A;
	                        CarInfo[i][ImpPrice] = price;
	                        CarInfo[i][Imp] = 1;
	                        SaveVehicleComponents(i);
	                        OnPropUpdate(3, i);
	                        DestroyVehicle(CarPickup[i]);
	                        CarPickup[i] = CreateVehicle(CarInfo[i][cModel],CarInfo[i][cLocationx],CarInfo[i][cLocationy],CarInfo[i][cLocationz],CarInfo[i][cAngle],CarInfo[i][cColorOne],CarInfo[i][cColorTwo],60000);
	                        SetVehicleModifications(i);
	                        ChangeVehiclePaintjob(i, CarInfo[i][cPaintjob]);
	                        SendClientMessage(playerid, COLOR_YELLOW, "Vehicle Impounded");
	                        return 1;
	                    }
	                    else
	                        return SendClientMessage(playerid, COLOR_GREY, "You can't impound vehicle's that is not owned!");
	                }
				}
            }
            if(FoundCar == 0)
            {
                SendClientMessage(playerid, COLOR_GREY, "You have to be close to a ownable vehicle!");
                return 1;
			}
        }
        return 1;
    }
Can't test it, but should work.

EDIT: Should probably have used a break system instead but on my phone now so can't adjust it.
Reply
#3

Thanks it works
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)