SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 13/01/2018, 04:37 PM   #1
Osamakurdi
Big Clucker
 
Join Date: Mar 2017
Location: Syria
Posts: 95
Reputation: 10
Default help me sellcarto

I Have These 2 Commands They are wroking:
First One:
When Player Enter Vehicle it will show dialog
And This what its do.
Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if(dialogid == 669)
	{
	    if(response)
	    {
	        new file[256], name[MAX_PLAYER_NAME];
    		GetPlayerName(playerid, name, sizeof(name));
			format(file,sizeof(file),"Cars/%s.ini",name);
            new veh = GetPlayerVehicleID(playerid);
		    new money = GetPlayerMoney(playerid);
	        if(money >= CarPrice[veh])
	        {
	            if(gPlayerHasCar[playerid] == 1) return SendClientMessage(playerid, 0xFFFFFFFF, "You already own a car.");
	            new string[64];
	            SendClientMessage(playerid, 0xAFAFAFAA, "Thank you for buying at Coutt and Schutz.");
	            PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
				dini_Create(file);
				Vehicle[playerid] = CreateVehicle(GetVehicleModel(veh), 2130.1914, -1109.5881, 25.1890, 76.2599, 1, 1, 3600000);
                format(string, sizeof(string), "Creating your vehicle %i.", veh);
	            SendClientMessage(playerid, 0xAFAFAFAA, string);
				VehicleInfo[playerid][Model] = GetVehicleModel(veh);
				VehicleInfo[playerid][Price] = CarPrice[veh];
				VehicleInfo[playerid][CarX] = 2130.1914;
				VehicleInfo[playerid][CarY] = -1109.5881;
				VehicleInfo[playerid][CarZ] = 25.1890;
				VehicleInfo[playerid][CarRot] = 76.2599;
				gPlayerHasCar[playerid] = 1;
				RemovePlayerFromVehicle(playerid);
				OwnerID[Vehicle[playerid]] = playerid;
				VehPlate[Vehicle[playerid]] = "XYZR 000";
				PutPlayerInVehicle(playerid, Vehicle[playerid], 0);
				GivePlayerMoney(playerid, -VehicleInfo[playerid][Price]);
			}
			else
			{
			    RemovePlayerFromVehicle(playerid);
			    SendClientMessage(playerid, 0xAFAFAFAA, "You cannot afford this vehicle.");
			    return 1;
   			}
		}
		else
		{
  			RemovePlayerFromVehicle(playerid);
		}
	}
Second One:
This sell car to no one :
Code:
	if(strcmp(cmd, "/sellcar", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
     	    if(!IsPlayerInVehicle(playerid, Vehicle[playerid]))
   		    {
   		    	SendClientMessage(playerid, 0xFFFFFFAA, "You are not in a car that you own.");
				return 1;
			}
			if(ConfirmSale[playerid] == 0) {
				SendClientMessage(playerid, 0xFFFF00FF, "Are you sure you want to sell your car? (Type /sellcar again to confirm).");
				ConfirmSale[playerid] = 1;
				return 1;
			}
   			new string[128], file[256], name[MAX_PLAYER_NAME];
    		GetPlayerName(playerid, name, sizeof(name));
			format(file,sizeof(file),"Cars/%s.ini",name);
			format(string, sizeof(string), "You have sold your car for a 50 percent value, for $%i.", VehicleInfo[playerid][Price]/2);
			GivePlayerMoney(playerid, VehicleInfo[playerid][Price]/2);
		 	DestroyVehicle(Vehicle[playerid]);
			dini_Remove(file);
			Vehicle[playerid] = 0;
			gPlayerHasCar[playerid] = 0;
	  		VehicleInfo[playerid][Model] = 0;
			VehicleInfo[playerid][Price] = 0;
			VehicleInfo[playerid][CarX] = 0;
			VehicleInfo[playerid][CarY] = 0;
			VehicleInfo[playerid][CarZ] = 0;
			VehicleInfo[playerid][CarRot] = 0;
			ConfirmSale[playerid] = 0;
		 	SendClientMessage(playerid, 0xFFFF00FF, string);
			return 1;
		}
		return 1;
	}
Help Me !!! /sellcarto[playerid][money]
Code:
CMD:sellcarto(playerid, params[])
{
	new targetid, money;
	if(sscanf(params, "ui", targetid, money)) return SendClientMessage(playerid, 0xFFFF00FF, "USAGE:/sellcarto[playerid][money]");
	if(targetid == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFFFF00FF, "Player Not Connected.");
	return 1;
}
Osamakurdi is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create command /sellcarto ??? Eley999 Scripting Help 3 31/01/2013 10:02 PM


All times are GMT. The time now is 12:37 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.