change veh location create
#1

Code:
if(strcmp(x_nr,"sell",true) == 0)
	        {
	            if(IsAtDealership(playerid))
	            {
	                if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey])
	                {
	                    GetPlayerName(playerid, sendername, sizeof(sendername));
	                    new ownvehkey;
	                    if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { ownvehkey = PlayerInfo[playerid][pPcarkey]; }
	                    else { return 1; }
	                    if(strcmp(sendername, CarInfo[ownvehkey][cOwner], true) == 0)
	                    {
	                        new carsellprice = CarInfo[ownvehkey][cValue] / 4 * 3;
	                        new Float:x,Float:y,Float:z;
	                        new Float:a;
	                        CarInfo[ownvehkey][cOwned] = 0;
	                        strmid(CarInfo[ownvehkey][cOwner], "Dealership", 0, strlen("Dealership"), 999);
	                        GivePlayerMoney(playerid,carsellprice);
	                        PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
	                        format(string, sizeof(string), "~w~You have sold your car for: ~n~~g~$%d", carsellprice);
	                        GameTextForPlayer(playerid, string, 10000, 3);
	                        GetVehiclePos(ownvehkey, x, y, z);
	                        GetVehicleZAngle(ownvehkey, a);
	                        CarInfo[ownvehkey][cLocationx] = x; CarInfo[ownvehkey][cLocationy] = y; CarInfo[ownvehkey][cLocationz] = z; CarInfo[ownvehkey][cAngle] = a;
	                        CarInfo[ownvehkey][mod1] = 0; CarInfo[ownvehkey][mod2] = 0; CarInfo[ownvehkey][mod3] = 0; CarInfo[ownvehkey][mod4] = 0;
	                        CarInfo[ownvehkey][mod5] = 0; CarInfo[ownvehkey][mod6] = 0; CarInfo[ownvehkey][mod7] = 0; CarInfo[ownvehkey][mod8] = 0;
	                        CarInfo[ownvehkey][mod9] = 0; CarInfo[ownvehkey][mod10] = 0; CarInfo[ownvehkey][mod11] = 0; CarInfo[ownvehkey][mod12] = 0;
							CarInfo[ownvehkey][mod13] = 0; CarInfo[ownvehkey][mod14] = 0; CarInfo[ownvehkey][mod15] = 0; CarInfo[ownvehkey][mod16] = 0;
	                        CarInfo[ownvehkey][mod17] = 0; CarInfo[ownvehkey][paintjob] = -1;
	                        if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { PlayerInfo[playerid][pPcarkey] = -1; }
	                        RemovePlayerFromVehicle(playerid);
	                        TogglePlayerControllable(playerid, 1);
	                        format(CarInfo[vehid][cLicense], 32 ,"ForSale");
	                        SetVehicleNumberPlate(vehid,CarInfo[vehid][cLicense]);
	                        OnPropUpdate(); OnPlayerUpdateEx(playerid);
	                        DestroyVehicle(ownvehkey);
							new thiscar = CreateVehicle(CarInfo[ownvehkey][cModel],CarInfo[ownvehkey][cLocationx],CarInfo[ownvehkey][cLocationy],CarInfo[ownvehkey][cLocationz]+1.0,CarInfo[ownvehkey][cAngle],CarInfo[ownvehkey][cColorOne],CarInfo[ownvehkey][cColorTwo],60000);
							LoadComponents(thiscar);
	                        return 1;
	                    }
	                }
	                else
	                {
	                    SendClientMessage(playerid, COLOR_GREY, "  You have to sit at your own car to sell it! ");
	                    return 1;
	                }
	            }
	            else
	            {
	                SendClientMessage(playerid, COLOR_GREY, "You are not at a dealership");
	                return 1;
	            }
	        }
]

this is the code, how can i make, when i type /v sell to spawn the vehicle in a parking ? ( random ) but if is a car there, spawn at other place...
Reply
#2

Use SetVehiclePos(vehicleid, Float:X, Float:Y, Float:Z); to put the car at the dealership.
Use a loop trough all the vehicles and get their position and then compare that position to the position of the dealership, if true, use SetVehiclePos, but then with different cords.

Example for the loop:

pawn Code:
new bool CarAtDealerShip[MAX_VEHICLES] = false; // somewhere on top of your script.

for(i = 0; i < MAX_VEHICLES; i++) // Looping trough all the vehicles in the server.
{
    new Float:X, Float:Y, Float:Z;
    GetVehiclePos(i, Float:X, Float:Y, Float:Z);
    if(Float:X == Your_Cord && Float:Y == Your_Cord && Float:Z == Your_Cord)
    {
         CarAtDealership[i] = true;
    }
    else
    {
          CarAtDealership[i] = false;
    }
}
Now simply put the bool CarAtDealership before the SetVehiclePos in your command, and fill in your cords
Reply
#3

Code:
if(strcmp(x_nr,"sell",true) == 0)
	        {
	            if(IsAtDealership(playerid))
	            {
	                if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey])
	                {
	                    GetPlayerName(playerid, sendername, sizeof(sendername));
	                    new ownvehkey;
	                    if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { ownvehkey = PlayerInfo[playerid][pPcarkey]; }
	                    else { return 1; }
	                    if(strcmp(sendername, CarInfo[ownvehkey][cOwner], true) == 0)
	                    {
	                        new carsellprice = CarInfo[ownvehkey][cValue] / 4 * 3;
	                        new Float:x,Float:y,Float:z;
	                        new Float:a;
	                        CarInfo[ownvehkey][cOwned] = 0;
	                        strmid(CarInfo[ownvehkey][cOwner], "Dealership", 0, strlen("Dealership"), 999);
	                        GivePlayerMoney(playerid,carsellprice);
	                        PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
	                        format(string, sizeof(string), "~w~You have sold your car for: ~n~~g~$%d", carsellprice);
	                        GameTextForPlayer(playerid, string, 10000, 3);
	                        GetVehiclePos(ownvehkey, x, y, z);
	                        GetVehicleZAngle(ownvehkey, a);
	                        CarInfo[ownvehkey][cLocationx] = x; CarInfo[ownvehkey][cLocationy] = y; CarInfo[ownvehkey][cLocationz] = z; CarInfo[ownvehkey][cAngle] = a;
	                        CarInfo[ownvehkey][mod1] = 0; CarInfo[ownvehkey][mod2] = 0; CarInfo[ownvehkey][mod3] = 0; CarInfo[ownvehkey][mod4] = 0;
	                        CarInfo[ownvehkey][mod5] = 0; CarInfo[ownvehkey][mod6] = 0; CarInfo[ownvehkey][mod7] = 0; CarInfo[ownvehkey][mod8] = 0;
	                        CarInfo[ownvehkey][mod9] = 0; CarInfo[ownvehkey][mod10] = 0; CarInfo[ownvehkey][mod11] = 0; CarInfo[ownvehkey][mod12] = 0;
							CarInfo[ownvehkey][mod13] = 0; CarInfo[ownvehkey][mod14] = 0; CarInfo[ownvehkey][mod15] = 0; CarInfo[ownvehkey][mod16] = 0;
	                        CarInfo[ownvehkey][mod17] = 0; CarInfo[ownvehkey][paintjob] = -1;
	                        if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { PlayerInfo[playerid][pPcarkey] = -1; }
	                        RemovePlayerFromVehicle(playerid);
	                        TogglePlayerControllable(playerid, 1);
	                        format(CarInfo[vehid][cLicense], 32 ,"ForSale");
	                        SetVehicleNumberPlate(vehid,CarInfo[vehid][cLicense]);
	                        OnPropUpdate(); OnPlayerUpdateEx(playerid);
	                        DestroyVehicle(ownvehkey);
							new thiscar = CreateVehicle(CarInfo[ownvehkey][cModel],CarInfo[ownvehkey][cLocationx],CarInfo[ownvehkey][cLocationy],CarInfo[ownvehkey][cLocationz]+1.0,CarInfo[ownvehkey][cAngle],CarInfo[ownvehkey][cColorOne],CarInfo[ownvehkey][cColorTwo],60000);
							LoadComponents(thiscar);
							for(i = 0; i < MAX_VEHICLES; i++) // Looping trough all the vehicles in the server.
							{
    							new Float:X, Float:Y, Float:Z;
    							GetVehiclePos(i, Float:X, Float:Y, Float;Z);
    							if(Float:X == 1691.1671 && Float:Y == -1069.8132 && Float:Z == 23.6783)
    							{
         							CarAtDealership[i] = true;
   								}
   								else
   								{
          							CarAtDealership[i] = false;
   								}
   								SetVehiclePos(thiscar, x, y, z);
							}
	                        return 1;
	                    }
	                }
	                else
	                {
	                    SendClientMessage(playerid, COLOR_GREY, "  You have to sit at your own car to sell it! ");
	                    return 1;
	                }
	            }
	            else
	            {
	                SendClientMessage(playerid, COLOR_GREY, "You are not at a dealership");
	                return 1;
	            }
	        }
like that ? i get:
Code:
D:\SAMP Server R5\gamemodes\new.pwn(20580) : error 017: undefined symbol "i"
D:\SAMP Server R5\gamemodes\new.pwn(20580) : warning 205: redundant code: constant expression is zero
D:\SAMP Server R5\gamemodes\new.pwn(20580) : error 017: undefined symbol "i"
D:\SAMP Server R5\gamemodes\new.pwn(20580) : warning 215: expression has no effect
D:\SAMP Server R5\gamemodes\new.pwn(20580) : error 001: expected token: ")", but found ";"
D:\SAMP Server R5\gamemodes\new.pwn(20580) : fatal error 107: too many error messages on one line
Reply
#4

Change the loop to
pawn Code:
for(new i = 0; i < MAX_VEHICLES; i++)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)