[FilterScript] [FS] Vehicle System ver. 2 UPDATED!
#1

HI
VERSION 2:
fixed alot of bugs.
each vehicle has it own file.
the vehicles are not added by this script cant be bought.
fixed the unknown commands in pawno with clear ones. (SetPlayerMoney...)


What is this FS??
this is a filter-script i made that can allow players to buy and sell cars or planes...

COMMANDS:
/vbuy
/vsell

HOW TO ADD CARS
you can add a buyable car by adding this to OnFilterScriptInit()

Код:
AddCar(Filename[], CarMod, Cost, Float:Spawnx, Float:Spawny, Float:Spawnz, Rot, Col1,Col2)
you should change them to your own... explain:

FileName[] : the vehicle file name ex. car1
CarMod : the model of the car ex.411 = infernus... you can get them from here: https://sampwiki.blast.hk/wiki/Vehicles:All
Cost : the price of the car
Float:Spawnx : The X-coordinate of the vehicle
Float:Spawny : The Y-coordinate of the vehicle
Float:Spawnz : The Z-coordinate of the vehicle
Rot : The rotation of the vehicle
Col1 : Color 1 of the vehicle
Col2 : Color 2 of the vehicle

example

Код:
AddCar("Infernus", 411, 5000, 2019.5199, -1253.3680, 23.7115, 116, 12, 12);
DOWNLOADS:


Credits:
[SB]Unforseen

hope you like that filter-script and remember its simple car system.
Reply
#2

Quote:
Originally Posted by xenowortt
ohh good! Nice work!
thank
Reply
#3

Fatal error in 100 ?

Код:
#include <a_samp>
#include <dini>

#define MAX_CARS 200

#define RED 0xF60000AA

enum carinfo
{
    CarNames[60], //To save into the file
    CarModel, //The Car model
    CarCost, //The car cost
    CarOwner[24], // The car owners Name
    CarIsBought, //If the car is brought or not
    Float:SpawnX, // PickupX
    Float:SpawnY, //PickupY
    Float:SpawnZ, //PickupZ
    Color1,
    Color2,
    Rotation,
    Owned,
}

new CarInfo[MAX_CARS][carinfo];
new CarCount = -1; //Car count



stock AddCar(Filename[], CarMod, Cost, Float:Spawnx, Float:Spawny, Float:Spawnz, Rot, Col1, Col2)
{
  if(!dini_Exists("Cars.ini"))
  {
    dini_Create("Cars.ini");
  }
  CarCount ++;
  new ID = CarCount; //CarID
  format(CarInfo[ID][CarNames], 60, "%s", Filename); //Saves the Car Name into a variable
  CarInfo[ID][CarIsBought] = 0;
  CarInfo[ID][SpawnX] = Spawnx;
  CarInfo[ID][SpawnY] = Spawny;
  CarInfo[ID][SpawnZ] = Spawnz;
  CarInfo[ID][CarModel] = CarMod;
  CarInfo[ID][Color1] = Col1;
  CarInfo[ID][Color2] = Col2;
  CarInfo[ID][Rotation] = Rot;
  if(strlen(dini_Get("Cars.ini", Filename))) //This is to see if there is any owner.
  {
    format(CarInfo[ID][CarOwner], 24, "%s", dini_Get("Cars.ini", Filename));
    CarInfo[ID][Owned] = 1;
  }
  AddStaticVehicle(CarMod,Spawnx,Spawny,Spawnz,Rot,Col1,Col2); // car
}


public OnGameModeInit()
{
	AddCar("Bullet", 411, 5000, 2019.5199, -1253.3680, 23.7115, 116, 12, 12);System Loaded"); 
  AddCar("Huntley", 579, 12345, 1560.7213, -2254.2932, 13.4793, 270.1003, 42, 42);
	return 1;
}



public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" [SB] Car System Loaded");
	print("--------------------------------------\n");
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
  if (strcmp("/vbuy", cmdtext) == 0)
  {
    for(new i; i<MAX_CARS; i++)
        {
  	      if(IsPlayerInAnyVehicle(playerid))
        {
        new Pname[24]; GetPlayerName(playerid, Pname, 24);
        if(strlen(dini_Get("Cars.ini", Pname)))
        if(GetPlayerMoney(playerid) < CarInfo[i][CarCost]) return SendClientMessage(playerid, 0xF60000AA, "You don't have enough money to buy this Car!");
        if(CarInfo[i][Owned] == 1) return SendClientMessage(playerid, 0xF60000AA, "This Car is already owned!");
        SetPlayerMoney(playerid, GetPlayerMoney(playerid) - CarInfo[i][CarCost]);
        GameTextForPlayer(playerid, "~r~Car Purchased!", 2000, 3);
        CarInfo[i][Owned] = 1;
        format(CarInfo[i][CarOwner], 24, "%s", Pname);
        dini_Set("Cars.ini", Pname, CarInfo[i][CarNames]);
        return 1;
        }
        else if(!IsPlayerInAnyVehicle(playerid))
        {
        SendClientMessage(playerid, RED, "You must be in a car!");
        }
        
        else if(GetPlayerVehicleID(playerid) != CarInfo[i][CarNames])
        {
        SendClientMessage(playerid, RED, "Unsupported Car!");
        }
        }
    return 1;
  }
  if (strcmp("/vsell", cmdtext) == 0)
  {
    for(new i; i<MAX_CARS; i++)
        {
  	      if(IsPlayerInAnyVehicle(playerid))
        {
        new Pname[24]; GetPlayerName(playerid, Pname, 24);
        if(strcmp(Pname, CarInfo[i][CarOwner]) != 0) return SendClientMessage(playerid, 0xF60000AA, "You don't own this Car!");
        GivePlayerMoney(playerid, CarInfo[i][CarCost]);
        GameTextForPlayer(playerid, "~g~Car Sold!", 2000, 3);
        CarInfo[i][Owned] = 0;
        CarInfo[i][CarOwner] = EOS;
        dini_Unset("Cars.ini", Pname);
        return 1;
        }
        else if(!IsPlayerInAnyVehicle(playerid))
				{
        SendClientMessage(playerid, RED, "You are not in a vehicle!");
        }
  }
        
  }
  return 0;
}
Reply
#4

Show me the exact error
Reply
#5

Bullet has System Loaded" extra
Reply
#6

Quote:
Originally Posted by jocki
Fatal error in 100 ?

Код:
#include <a_samp>
#include <dini>

#define MAX_CARS 200

#define RED 0xF60000AA

enum carinfo
{
    CarNames[60], //To save into the file
    CarModel, //The Car model
    CarCost, //The car cost
    CarOwner[24], // The car owners Name
    CarIsBought, //If the car is brought or not
    Float:SpawnX, // PickupX
    Float:SpawnY, //PickupY
    Float:SpawnZ, //PickupZ
    Color1,
    Color2,
    Rotation,
    Owned,
}

new CarInfo[MAX_CARS][carinfo];
new CarCount = -1; //Car count



stock AddCar(Filename[], CarMod, Cost, Float:Spawnx, Float:Spawny, Float:Spawnz, Rot, Col1, Col2)
{
  if(!dini_Exists("Cars.ini"))
  {
    dini_Create("Cars.ini");
  }
  CarCount ++;
  new ID = CarCount; //CarID
  format(CarInfo[ID][CarNames], 60, "%s", Filename); //Saves the Car Name into a variable
  CarInfo[ID][CarIsBought] = 0;
  CarInfo[ID][SpawnX] = Spawnx;
  CarInfo[ID][SpawnY] = Spawny;
  CarInfo[ID][SpawnZ] = Spawnz;
  CarInfo[ID][CarModel] = CarMod;
  CarInfo[ID][Color1] = Col1;
  CarInfo[ID][Color2] = Col2;
  CarInfo[ID][Rotation] = Rot;
  if(strlen(dini_Get("Cars.ini", Filename))) //This is to see if there is any owner.
  {
    format(CarInfo[ID][CarOwner], 24, "%s", dini_Get("Cars.ini", Filename));
    CarInfo[ID][Owned] = 1;
  }
  AddStaticVehicle(CarMod,Spawnx,Spawny,Spawnz,Rot,Col1,Col2); // car
}


public OnGameModeInit()
{
	AddCar("Bullet", 411, 5000, 2019.5199, -1253.3680, 23.7115, 116, 12, 12);System Loaded"); 
  AddCar("Huntley", 579, 12345, 1560.7213, -2254.2932, 13.4793, 270.1003, 42, 42);
	return 1;
}



public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" [SB] Car System Loaded");
	print("--------------------------------------\n");
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
  if (strcmp("/vbuy", cmdtext) == 0)
  {
    for(new i; i<MAX_CARS; i++)
        {
 	      if(IsPlayerInAnyVehicle(playerid))
        {
        new Pname[24]; GetPlayerName(playerid, Pname, 24);
        if(strlen(dini_Get("Cars.ini", Pname)))
        if(GetPlayerMoney(playerid) < CarInfo[i][CarCost]) return SendClientMessage(playerid, 0xF60000AA, "You don't have enough money to buy this Car!");
        if(CarInfo[i][Owned] == 1) return SendClientMessage(playerid, 0xF60000AA, "This Car is already owned!");
        SetPlayerMoney(playerid, GetPlayerMoney(playerid) - CarInfo[i][CarCost]);
        GameTextForPlayer(playerid, "~r~Car Purchased!", 2000, 3);
        CarInfo[i][Owned] = 1;
        format(CarInfo[i][CarOwner], 24, "%s", Pname);
        dini_Set("Cars.ini", Pname, CarInfo[i][CarNames]);
        return 1;
        }
        else if(!IsPlayerInAnyVehicle(playerid))
        {
        SendClientMessage(playerid, RED, "You must be in a car!");
        }
        
        else if(GetPlayerVehicleID(playerid) != CarInfo[i][CarNames])
        {
        SendClientMessage(playerid, RED, "Unsupported Car!");
        }
        }
    return 1;
  }
  if (strcmp("/vsell", cmdtext) == 0)
  {
    for(new i; i<MAX_CARS; i++)
        {
 	      if(IsPlayerInAnyVehicle(playerid))
        {
        new Pname[24]; GetPlayerName(playerid, Pname, 24);
        if(strcmp(Pname, CarInfo[i][CarOwner]) != 0) return SendClientMessage(playerid, 0xF60000AA, "You don't own this Car!");
        GivePlayerMoney(playerid, CarInfo[i][CarCost]);
        GameTextForPlayer(playerid, "~g~Car Sold!", 2000, 3);
        CarInfo[i][Owned] = 0;
        CarInfo[i][CarOwner] = EOS;
        dini_Unset("Cars.ini", Pname);
        return 1;
        }
        else if(!IsPlayerInAnyVehicle(playerid))
				{
        SendClientMessage(playerid, RED, "You are not in a vehicle!");
        }
  }
        
  }
  return 0;
}
What error exactly?
Reply
#7

C:\Dokumente und Einstellungen\Tim Macik\Desktop\Cars.pwn(2) : fatal error 100: cannot read from file: "dini"

whats wrong?
Reply
#8

Looks like something ripped from Godfather.
Reply
#9

Search dini.inc in forums
Reply
#10

Quote:
Originally Posted by jocki
Посмотреть сообщение
C:\Dokumente und Einstellungen\Tim Macik\Desktop\Cars.pwn(2) : fatal error 100: cannot read from file: "dini"

whats wrong?
You have to include dini like this:
include <dini>
And then you have to put dini on pawn/includes
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)