You can sell the another player's car (/sellveh problem)
#1

I have the command /sellveh what sell your personal car to dealership. But there is a problem: With this command you can sell the vehicle of another player. How to make it work just for your personal vehicle?

Код:
if (strcmp("/sellveh", cmdtext, true, 10) == 0)
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, ORANGE, "You must be in a car for this action");
        if(GetCreatorID(vehicleid)!=0)
        {
       		format(file,64,"personalcars/%s.ini",VehicleSystem[vehicleid][owner]);
       		dini_Remove(file);
            new Float:vx,Float:vy,Float:vz,Float:va;
            GetVehiclePos(GetPlayerVehicleID(playerid),vx,vy,vz);
            GetVehicleZAngle(GetPlayerVehicleID(playerid),va);
            VehicleSystem[GetCreatorID(vehicleid)][xc]=vx;
            VehicleSystem[GetCreatorID(vehicleid)][yc]=vy;
            VehicleSystem[GetCreatorID(vehicleid)][zc]=vz;
            VehicleSystem[GetCreatorID(vehicleid)][ac]=va;
            Locked[GetCreatorID(vehicleid)] = 0;
	        VehicleSystem[GetCreatorID(vehicleid)][Lock] = 0;
            strmid(VehicleSystem[GetCreatorID(vehicleid)][owner],"dealercar",0,128,128);
            new create = GetCreatorID(vehicleid);
			DestroyVehicle(vehicleid);
   			new CAR = CreateVehicle(VehicleSystem[create][cmodel],VehicleSystem[create][xc],VehicleSystem[create][yc],VehicleSystem[create][zc],VehicleSystem[create][ac],VehicleSystem[create][Farbe1],VehicleSystem[create][Farbe2],-1);
			SetVehicleNumberPlate(CAR, VehicleSystem[GetCreatorID(vehicleid)][owner]);
			VehicleSystem[GetCreatorID(vehicleid)][mod1]=0;
	        VehicleSystem[GetCreatorID(vehicleid)][mod2]=0;
	        VehicleSystem[GetCreatorID(vehicleid)][mod3]=0;
	        VehicleSystem[GetCreatorID(vehicleid)][mod4]=0;
	        VehicleSystem[GetCreatorID(vehicleid)][mod5]=0;
	        VehicleSystem[GetCreatorID(vehicleid)][mod6]=0;
	        VehicleSystem[GetCreatorID(vehicleid)][mod7]=0;
	        VehicleSystem[GetCreatorID(vehicleid)][mod8]=0;
	        VehicleSystem[GetCreatorID(vehicleid)][mod9]=0;
	        VehicleSystem[GetCreatorID(vehicleid)][mod10]=0;
	        VehicleSystem[GetCreatorID(vehicleid)][mod11]=0;
	        VehicleSystem[GetCreatorID(vehicleid)][mod12]=0;
	        VehicleSystem[GetCreatorID(vehicleid)][mod13]=0;
	        VehicleSystem[GetCreatorID(vehicleid)][mod14]=0;
	        VehicleSystem[GetCreatorID(vehicleid)][mod15]=0;
	        VehicleSystem[GetCreatorID(vehicleid)][mod16]=0;
	        VehicleSystem[GetCreatorID(vehicleid)][mod17]=0;
	        VehicleSystem[GetCreatorID(vehicleid)][paintjob]=255;
	        VehicleSystem[GetCreatorID(vehicleid)][Farbe1]=1;
	        VehicleSystem[GetCreatorID(vehicleid)][Farbe2]=1;
	        ChangeVehicleColor(vehicleid, 1,1);
            SendClientMessage(playerid, COLOR_WHITE, "This car is now for sale! ");
        }
        return 1;
    }
I hope this can help you:
Код:
if(dini_Int(PFile(playerid),"HaveCar") == 0) return SendClientMessage(playerid, ORANGE, "[ERROR]You dont have a car");
Reply
#2

Look at this command:

Код:
if (strcmp("/parkmycar", cmdtext, true, 10) == 0)
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You must be in your car for this action");
        if(GetCreatorID(vehicleid)!=0)
        {
            if (strmatch(VehicleSystem[GetCreatorID(vehicleid)][owner],Spielername(playerid)))
            {
                new Float:VHealth;
                GetVehicleHealth(vehicleid, VHealth);
                if(VHealth >= 550)
                {
	                new Float:vx,Float:vy,Float:vz,Float:va;
	                GetVehiclePos(GetPlayerVehicleID(playerid),vx,vy,vz);
	                GetVehicleZAngle(GetPlayerVehicleID(playerid),va);
	                VehicleSystem[GetCreatorID(vehicleid)][xc]=vx;
	                VehicleSystem[GetCreatorID(vehicleid)][yc]=vy;
	                VehicleSystem[GetCreatorID(vehicleid)][zc]=vz;
	                VehicleSystem[GetCreatorID(vehicleid)][ac]=va;
	                SendClientMessage(playerid,COLOR_WHITE,"Masina a fost parcata aici!");
	                SendClientMessage(playerid,COLOR_YELLOW,"NOTE:Masina a fost Respawnata pentru a se salva locatia!");
	               	new Float:slx, Float:sly, Float:slz;
					GetPlayerPos(playerid, slx, sly, slz);
					SetPlayerPos(playerid, slx+1.3, sly, slz);
					new create = GetCreatorID(vehicleid);
					DestroyVehicle(vehicleid);
	        		new CAR = CreateVehicle(VehicleSystem[create][cmodel],VehicleSystem[create][xc],VehicleSystem[create][yc],VehicleSystem[create][zc],VehicleSystem[create][ac],VehicleSystem[create][Farbe1],VehicleSystem[create][Farbe2],-1);
	        		SetVehicleNumberPlate(CAR, VehicleSystem[GetCreatorID(vehicleid)][owner]);
	        		Tunen(CAR);
				}
				else
				{
				    SendClientMessage(playerid, COLOR_GREY, "* Vehicle health to low! ");
				}
            }
        }
        return 1;
    }
i want to put "You must be in your car for this action" in the /sellveh command
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)