SA-MP Forums Archive
Help with script!! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with script!! (/showthread.php?tid=223259)



Help with script!! - showarn - 09.02.2011

Hello if any1 could take a look on this script i got 2 bugs with it 1 rly important

So here is the bug
1#When i bought a vehicle its spawn with me in it and the i use /v lock /v sell etc etc it says you dont own a vehicle?humm and also when i use other such of vehicle commands its says the same what can the problem be?

2#When some1 has bought a car and some1 steels it and park it far away the car will be spawned there the last guy putted the char becouse the car are saving or somthing i want it to be parked on the car dealership if the owner of the car hasnt used /v park




i use this Script in my gm


Код:
	new vehid;
		tmp = strtok(cmdtext, idx);
		if (!strlen(tmp))
	    {
		    SendClientMessage(playerid, COLOR_GREY, "USAGE: /destroycdveh [vehicleid]");
		    return 1;
	    }
		vehid = strval(tmp);
		DestroyCarDealershipVehicle(GetCarDealershipId(vehid), GetCarDealershipVehicleId(vehid));
		format(string, sizeof(string), " Car Dealership Vehicle destroyed with ID %d.", vehid);
		SendClientMessage(playerid, COLOR_GRAD1, string);
	}
	if(strcmp(cmd, "/createdealership", true) == 0)
	{
	    if (PlayerInfo[playerid][pAdmin] < 5)
	    {
	        SendClientMessage(playerid, COLOR_GREY, " You are not allowed to use this command.");
	        return 1;
	    }
		tmp = strtok(cmdtext,idx);
		new radius;
		if (!strlen(tmp))
	    {
		    SendClientMessage(playerid, COLOR_GREY, "USAGE: /createdealership [price] [radius] [message]");
		    return 1;
	    }
	    new price = strval(tmp);
		tmp = strtok(cmdtext, idx);
		if (!strlen(tmp))
	    {
		    SendClientMessage(playerid, COLOR_GREY, "USAGE: /createdealership [price] [radius] [message]");
		    return 1;
	    }
	    radius = strval(tmp);
	    new length = strlen(cmdtext);
		while ((idx < length) && (cmdtext[idx] <= ' '))
		{
			idx++;
		}
		new offset = idx;
		new result[64];
		while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
		{
			result[idx - offset] = cmdtext[idx];
			idx++;
		}
		result[idx - offset] = EOS;
		if(!strlen(result))
		{
			SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /createdealership [price] [radius] [message]");
			return 1;
		}
		new Float:X,Float:Y,Float:Z;
	    GetPlayerPos(playerid,X,Y,Z);
	    new dealershipid = CreateCarDealership(X, Y, Z, radius, price, result);
	    if(dealershipid == -1)
		{
		    SendClientMessage(playerid, COLOR_GREY, "ERROR: Car Dealerships limit reached.");
		}
	    else
	    {
            format(string, sizeof(string), " Car Dealership created with ID %d.", dealershipid);
		    SendClientMessage(playerid, COLOR_GRAD1, string);
	    }
	}
	if(strcmp(cmd, "/destroydealership", true) == 0)
	{
	    if (PlayerInfo[playerid][pAdmin] < 5)
	    {
	        SendClientMessage(playerid, COLOR_GREY, " You are not allowed to use this command.");
	        return 1;
	    }
	    for(new d = 0 ; d < MAX_CARDEALERSHIPS; d++)
	    {
		   if(IsPlayerInRangeOfPoint(playerid, 3.0, CarDealershipInfo[d][cdEntranceX], CarDealershipInfo[d][cdEntranceY], CarDealershipInfo[d][cdEntranceZ]))
		   {
			   DestroyCarDealership(d);
			   format(string, sizeof(string), " Car Dealership destroyed with ID %d.", d);
		       SendClientMessage(playerid, COLOR_GRAD1, string);
			   return 1;
		   }
		}
		new dealershipid;
		tmp = strtok(cmdtext, idx);
		if (!strlen(tmp))
	    {
		    SendClientMessage(playerid, COLOR_GREY, "USAGE: /destroydealership [dealershipid]");
		    return 1;
	    }
		dealershipid = strval(tmp);
		if(dealershipid > MAX_CARDEALERSHIPS) return 1;
		if(dealershipid < 0) return 1;
		DestroyCarDealership(dealershipid);
		format(string, sizeof(string), " Car Dealership destroyed with ID %d.", dealershipid);
		SendClientMessage(playerid, COLOR_GRAD1, string);
	}
	if(strcmp(cmd, "/vehid", true) == 0)
	{
	    if(IsPlayerInAnyVehicle(playerid))
	    {
			format(string, sizeof(string), "* Vehicle Name: %s | Vehicle ID: %d.",GetVehicleName(idcar), idcar);
			SendClientMessage(playerid, COLOR_GREY, string);
		}
		return 1;
	}
	if(strcmp(cmd, "/createvehicle", true) == 0)
	{
	    if (PlayerInfo[playerid][pAdmin] < 5)
	    {
	        SendClientMessage(playerid, COLOR_GREY, " You are not allowed to use this command.");
	        return 1;
	    }
		tmp = strtok(cmdtext,idx);
		new modelid;
		if (!strlen(tmp))
	    {
		    SendClientMessage(playerid, COLOR_GREY, "USAGE: /createvehicle [playerid/partOfName] [modelid] [color 1] [color 2]");
		    return 1;
	    }
	    giveplayerid = ReturnUser(tmp);
		tmp = strtok(cmdtext, idx);
		if (!strlen(tmp))
	    {
		    SendClientMessage(playerid, COLOR_GREY, "USAGE: /createvehicle [playerid/partOfName] [modelid] [color 1] [color 2]");
		    return 1;
	    }
		modelid = strval(tmp);
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
		{
		    SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /createvehicle [playerid/partOfName] [modelid] [color 1] [color 2]");
			return 1;
		}
		new color1;
		color1 = strval(tmp);
		if(color1 < 0 || color1 > 126) { SendClientMessage(playerid, COLOR_GREY, "   Color Number can't be below 0 or above 126 !"); return 1; }
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
		{
			SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /createvehicle [playerid/partOfName] [modelid] [color 1] [color 2]");
			return 1;
		}
		new color2;
		color2 = strval(tmp);
		if(color2 < 0 || color2 > 126) { SendClientMessage(playerid, COLOR_GREY, "   Color Number can't be below 0 or above 126 !"); return 1; }
		if(modelid < 400 || modelid > 611) { SendClientMessage(playerid, COLOR_GREY, "   Vehicle Number can't be below 400 or above 611 !"); return 1; }
		new playervehicleid = GetPlayerFreeVehicleId(giveplayerid);
		if(playervehicleid == -1) return SendClientMessage(playerid, COLOR_GREY, "ERROR: That player can't have more cars.");
		new Float:X,Float:Y,Float:Z;
	    GetPlayerPos(giveplayerid,X,Y,Z);
	    new Float:Angle;
	    GetPlayerFacingAngle(giveplayerid,Angle);
	    new car = CreatePlayerVehicle(giveplayerid, playervehicleid, modelid, X, Y, Z, Angle, color1, color2);
	    if(car == INVALID_PLAYER_VEHICLE_ID)
		{
		    SendClientMessage(playerid, COLOR_GREY, "ERROR: Something went wrong and the car didn't got created.");
		}
	    else
	    {
            format(string, sizeof(string), " Vehicle successfully created with ID %d.", car);
		    SendClientMessage(playerid, COLOR_GRAD1, string);
	    }
	}
	if(strcmp(cmd, "/destroyvehicle", true) == 0)
	{
	    if (PlayerInfo[playerid][pAdmin] < 4)
	    {
	        SendClientMessage(playerid, COLOR_GREY, " You are not allowed to use this command.");
	        return 1;
	    }
		tmp = strtok(cmdtext,idx);
		new vehicleid;
		if (!strlen(tmp))
	    {
		    SendClientMessage(playerid, COLOR_GREY, "USAGE: /destroyvehicle [playerid/partOfName] [vehicleid]");
		    return 1;
	    }
	    giveplayerid = ReturnUser(tmp);
		tmp = strtok(cmdtext, idx);
		if (!strlen(tmp))
	    {
		    SendClientMessage(playerid, COLOR_GREY, "USAGE: /destroyvehicle [playerid/partOfName] [vehicleid]");
		    return 1;
	    }
		vehicleid = strval(tmp);
		new playervehicleid = GetPlayerVehicle(giveplayerid, vehicleid);
		if(playervehicleid == -1) return SendClientMessage(playerid, COLOR_GREY, "ERROR: That player doesn't own that vehicle.");
		DestroyPlayerVehicle(giveplayerid, playervehicleid);
	}
	if (strcmp(cmdtext, "/map", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
        	if (PlayerToPoint(3, playerid, 1737.1313,-2238.4797,13.5439))
        	{
        	   	ShowPlayerDialog(playerid, MAPMENU, DIALOG_STYLE_LIST, "LS Map","Gym\nSAST\nLSPD\nAll Saints\nStadium\nPrison\nBank\nCityhall\n24-7\nLicenses Department\nPaintball\nChop Shop", "Mark", "Cancel");
        	   	LSMap[playerid] = 1;
	    	}
    	}
    	return 1;
   	}
and here is my "Alex_slav car file"

Код:
AH_Typ=-1
AH_X=0.000000
AH_Y=0.000000
AH_Z=0.000000
AH_Rot=0.000000
AH_Status=0
AH_Lock=0
AH_Paintjob=-1
AH_Color1=-1
AH_Color2=-1
AH_mod1=-1
AH_mod2=-1
AH_mod3=-1
AH_mod4=-1
AH_mod5=-1
AH_mod6=-1
AH_mod7=-1
AH_mod8=-1
AH_mod9=-1
AH_mod10=-1
AH_mod11=-1
AH_mod12=-1
AH_mod13=-1
AH_mod14=-1
AH_mod15=-1
AH_mod16=-1
AH_mod17=-1

Please take a look