/sellveh bug
#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?

An example, look at this command. Here you can park just YOUR VEHICLE:
Код:
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;
    }
How to make the same on the command /sellveh?:

Код:
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;
    }
Reply
#2

COme on.. its so hard?
Reply
#3

My guess:
pawn Код:
//Find lines:
if(GetCreatorID(vehicleid)!=0)
//Replace with
if(GetCreatorID(vehicleid) == playerid)
Reply
#4

Now the command doesnt work
Reply
#5

Ah, ok. Undo this change, I'm blind a little.
pawn Код:
//Find
if(GetCreatorID(vehicleid)!=0)
//Change to
if(GetCreatorID(vehicleid) != 0 && strmatch(VehicleSystem[GetCreatorID(vehicleid)][owner],Spielername(playerid)))
Do this only in your sellveh command (because you already have it implemented in parkveh).

Protip: it would be easier if you had stored owner id instead of nick.
Reply
#6

Wow thanks dude :X The command is now ok
+1 rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)