car ownership

6. Jul 2010.
3,641
pregleda
3
postova
mariomako
5
Underboss
6. Jul 2010.
zz, nasao sam car ownership skriptu bez /park pa sam kopirao od drugu takvu editovanu filterskriptu i samo sam ubacio /park ali dolazimi do ove errore
F:\CroMafia\filterscripts\CarOwnership.pwn(361) : error 028: invalid subscript (not an array or too many subscripts): "pCarKey"
F:\CroMafia\filterscripts\CarOwnership.pwn(361) : warning 215: expression has no effect
F:\CroMafia\filterscripts\CarOwnership.pwn(361) : error 001: expected token: ";", but found "]"
F:\CroMafia\filterscripts\CarOwnership.pwn(361) : error 029: invalid expression, assumed zero
F:\CroMafia\filterscripts\CarOwnership.pwn(361) : fatal error 107: too many error messages on one line


evo komandu /park
//park
if(strcmp(cmd,"/park",true)==0)
{
new vehicleid =  GetPlayerVehicleID(playerid);
if(pCarKey == 0) { SendClientMessage(playerid,COLOR_GRAD2," Nemas vlastito vozilo!"); return 1; }
if(IsPlayerConnected(playerid))
{
    for(new i = 0; i < sizeof(CarInfo); i++)
    {
    if(vehicleid == CarInfo)
    {
    new Float:x,Float:y,Float:z;
new Float:a;
GetVehiclePos(vehicleid, x, y, z);
GetVehicleZAngle(vehicleid, a);
CarInfo = x;
CarInfo = y;
CarInfo = z;
CarInfo = a;
}
}
}
SaveCars();
new Float:x;
new Float:y;
new Float:z;
new Float:a;
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);
new formatPARK;
format(formatPARK,sizeof(formatPARK),"Auto parkiran na kordinate X %d Y %d Z %d A %d",x,y,z,a);
SendClientMessage(playerid,COLOR_GREEN, formatPARK);
return 1;
}
return 0;
}


a evo cela filter skripta
//===========================Section: Includes==================================
#include
//===========================Section: Definations===============================
#define COLOR_GRAD1 0xB4B5B7FF
#define COLOR_GRAD2 0xBFC0C2FF
#define COLOR_GRAD3 0xCBCCCEFF
#define COLOR_GRAD4 0xD8D8D8FF
#define COLOR_GRAD5 0xE3E3E3FF
#define COLOR_GRAD6 0xF0F0F0FF
#define COLOR_GREEN 0x33AA33AA
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_YELLOW2 0xF5DEB3AA
//===========================Section: Forwards==================================
forward split(const strsrc[], strdest[][], delimiter);
forward LoadCar();
forward CheckOwner(playerid);
forward SaveCars();
//===========================Section: Variables=================================
enum pInfo
{
pCarKey,
}
new PlayerInfo;
enum cInfo
{
cModel,
Float:cLocationx,
Float:cLocationy,
Float:cLocationz,
Float:cAngle,
cColorOne,
cColorTwo,
cOwner,
cDescription,
cValue,
cLicense,
cRegistration,
cOwned,
cLock,
ownedvehicle,
};
new CarInfo;

new CarAutolock; // Variable for Autolocking Car Doors
new cartrack;
new CarOffered;
//===========================Section: strtok & split============================
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string <= ' '))
{
index++;
}

new offset = index;
new result;
while ((index < length) && (string > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string;
index++;
}
result[index - offset] = EOS;
return result;
}

public split(const strsrc[], strdest[][], delimiter)
{
new i, li;
new aNum;
new len;
while(i <= strlen(strsrc)){
    if(strsrc==delimiter || i==strlen(strsrc)){
        len = strmid(strdest, strsrc, li, i, 128);
        strdest = 0;
        li = i+1;
        aNum++;
}
i++;
}
return 1;
}
//===========================Section: Callbacks & Functions=====================
public OnFilterScriptInit()
{
printf("Filterscript CarOwnership.amx Initiated\n");
LoadCar();
for(new i = 1; i < sizeof(CarInfo); i++)
{
CarInfo = CreateVehicle(CarInfo,CarInfo,CarInfo,CarInfo,CarInfo,CarInfo,CarInfo,300000);
}
SetTimer("SaveCars",60000,1);
SetTimer("CheckOwner",5000,1);
return 1;
}
public OnVehicleSpawn(vehicleid)
{
for(new i = 1; i < sizeof(CarInfo); i++)
{
ChangeVehicleColor(CarInfo,CarInfo,CarInfo);
}
return 1;
}
public CheckOwner(playerid)
{
if(IsPlayerConnected(playerid))
{
    for(new i = 1; i < sizeof(CarInfo); i++)
    {
        new playername;
        GetPlayerName(playerid,playername,sizeof(playername));
        if(strcmp(playername,CarInfo,true)==0)
        {
            PlayerInfo = i;
return i;
        }
}
}
return 1;
}
public OnPlayerConnect(playerid)
{
PlayerInfo = 0;
CheckOwner(playerid);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new idx;
new string;
new cmd;
new tmp;
new sendername;
cmd = strtok(cmdtext, idx);
new vehid = GetPlayerVehicleID(playerid);
if(strcmp(cmd, "/carbuy", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        for(new i = 0; i < sizeof(CarInfo); i++)
        {
if(CarInfo == vehid)
{
if(PlayerInfo!=0)
{
SendClientMessage(playerid, COLOR_GREY, "You already own a car, type /car sell if you want to buy this one!");
return 1;
}
if(CarInfo==1)
{
    SendClientMessage(playerid, COLOR_GREY, "Someone already owns this car");
    return 1;
}
if(GetPlayerMoney(playerid) >= CarInfo)
{
PlayerInfo = i;
CarInfo = 1;
CarOffered=0;
GetPlayerName(playerid, sendername, sizeof(sendername));
strmid(CarInfo, sendername, 0, strlen(sendername), 999);
GivePlayerMoney(playerid,-CarInfo);
GameTextForPlayer(playerid, "~w~Congratulations~n~This is your car until you sell it!", 5000, 3);
SendClientMessage(playerid, COLOR_GRAD2, "Congratulations on your new purchase!");
SendClientMessage(playerid, COLOR_GRAD2, "Type /car manual to view the car manual!");
TogglePlayerControllable(playerid, 1);
SaveCars();
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, "  You don't have the cash for that!");
return 1;
}
}
}
}
return 1;
}
if(strcmp(cmd,"/car",true)==0)
{
new playername;
GetPlayerName(playerid,playername,sizeof(playername));
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
        SendClientMessage(playerid,COLOR_WHITE,"(( Use /car manual for detailed instructions for: ))");
        SendClientMessage(playerid,COLOR_WHITE,"(( CarOwnership by Ipuvaepe ))");
        return 1;
    }
    if(strcmp(tmp,"exit",true)==0)
    {
        CarOffered=0;
        RemovePlayerFromVehicle(playerid);
        TogglePlayerControllable(playerid, 1);
        return 1;
    }
if(strcmp(tmp, "manual", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        if(PlayerInfo!=0)
        {
format(string,sizeof(string),"________________%s________________",CarInfo[CheckOwner(playerid)]);
SendClientMessage(playerid, COLOR_GREEN,string);
SendClientMessage(playerid, COLOR_GRAD2,"** /carbuy - Buys the car (if for sale)");
SendClientMessage(playerid, COLOR_GRAD2,"** /car sell - Sells the car");
SendClientMessage(playerid, COLOR_GRAD2,"** /car manual - Shows this list");
SendClientMessage(playerid, COLOR_GRAD2,"** /car exit - Exits the car");
SendClientMessage(playerid, COLOR_GRAD2,"** /car locate - Uses the car's On-Star to locate");
SendClientMessage(playerid, COLOR_GRAD2,"** /car lock - Locks the car");
SendClientMessage(playerid, COLOR_GRAD2,"** /car unlock - Unlocks the car");
SendClientMessage(playerid, COLOR_GRAD2,"** /car autolock - Automatically locks the car upon exiting");
return 1;
}
else
{
    SendClientMessage(playerid,COLOR_GRAD2,"** You do not currently own a car! **");
    return 1;
}
}
return 1;
}
if(strcmp(tmp, "buy", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        for(new i = 0; i < sizeof(CarInfo); i++)
        {
if(CarInfo == vehid)
{
if(PlayerInfo!=0)
{
SendClientMessage(playerid, COLOR_GREY, "You already own a car, type /carsell if you want to buy this one!");
return 1;
}
if(CarInfo==1)
{
    SendClientMessage(playerid, COLOR_GREY, "Someone already owns this car");
    return 1;
}
if(GetPlayerMoney(playerid) >= CarInfo)
{
PlayerInfo = i;
CarInfo = 1;
CarOffered=0;
GetPlayerName(playerid, sendername, sizeof(sendername));
strmid(CarInfo, sendername, 0, strlen(sendername), 999);
GivePlayerMoney(playerid,-CarInfo);
GameTextForPlayer(playerid, "~w~Congratulations~n~This is your car until you sell it!", 5000, 3);
SendClientMessage(playerid, COLOR_GRAD2, "Congratulations on your new purchase!");
SendClientMessage(playerid, COLOR_GRAD2, "Type /manual to view the car manual!");
TogglePlayerControllable(playerid, 1);
SaveCars();
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, "  You don't have the cash for that!");
return 1;
}
}
}
}
return 1;
}
if(strcmp(tmp, "sell", true) == 0)
{
    if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, playername, sizeof(playername));
if(PlayerInfo == 0)
{
SendClientMessage(playerid, COLOR_GREY, "You don't own a car.");
return 1;
}
if(PlayerInfo != 0 && strcmp(playername, CarInfo[PlayerInfo], true) == 0)
{
new car = PlayerInfo;
CarInfo = 0;
GetPlayerName(playerid, sendername, sizeof(sendername));
strmid(CarInfo, "Dealership", 0, strlen("Dealership"), 999);
GivePlayerMoney(playerid,CarInfo);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
format(string, sizeof(string), "~w~You have sold your car for: ~n~~g~$%d", CarInfo);
GameTextForPlayer(playerid, string, 10000, 3);
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
PlayerInfo = 999;
return 1;
}
}
return 1;
}
if(strcmp(tmp, "locate", true) == 0)
{
    if(!IsPlayerConnected(playerid)) { return 1; }
    if(PlayerInfo == 0) { GameTextForPlayer(playerid, "~w~You do not have a car to locate", 2500, 3); return 1; }
    if(cartrack==0)
    {
        SendClientMessage(playerid,COLOR_WHITE,"On-Star: This is On-Star's automated vehicle tracking system");
        SendClientMessage(playerid,COLOR_WHITE,"On-Star: Please enter your PIN # and password now");
        SendClientMessage(playerid,COLOR_WHITE,"On-Star: Your vehicle's location is now uploaded to your phone");
        SetPlayerCheckpoint(playerid,CarInfo[PlayerInfo], CarInfo[PlayerInfo], CarInfo[PlayerInfo], 5.0);
        cartrack = 1;
        return 1;
}
else
{
        SendClientMessage(playerid,COLOR_WHITE,"On-Star: This is On-Star's automated vehicle tracking system");
        SendClientMessage(playerid,COLOR_WHITE,"On-Star: The tracking on your vehicle has been canceled");
        DisablePlayerCheckpoint(playerid);
        cartrack = 0;
        return 1;
}
}
if(strcmp(tmp, "lock", true) == 0)
    {
new keycar = PlayerInfo;
    if(IsPlayerConnected(playerid))
        {
for(new i = 0; i < MAX_PLAYERS; i++)
{
SetVehicleParamsForPlayer(CarInfo,i,0,1);
}
format(string, sizeof(string), "~w~Car~n~~r~Locked");
GameTextForPlayer(playerid, string, 10000, 3);
CarInfo = 1;
return 1;
}
}
if(strcmp(tmp, "unlock", true) == 0)
    {
new keycar = PlayerInfo;
    if(IsPlayerConnected(playerid))
        {
for(new i = 0; i < MAX_PLAYERS; i++)
{
SetVehicleParamsForPlayer(CarInfo,i,0,0);
}
format(string, sizeof(string), "~w~Car~n~~g~Unlocked");
GameTextForPlayer(playerid, string, 10000, 3);
CarInfo = 0;
return 1;
}
}
if(strcmp(tmp, "autolock", true) == 0)
    {
new keycar = PlayerInfo;
    if(CarAutolock[CarInfo] == 0) { CarAutolock[CarInfo] = 1; format(string, sizeof(string), "~w~Car Autolock~n~~r~Engaged"); return 1; }
    if(CarAutolock[CarInfo] == 1) { CarAutolock[CarInfo] = 0; format(string, sizeof(string), "~w~Car Autolock~n~~g~Disengaged"); return 1; }
    GameTextForPlayer(playerid, string, 10000, 3);
    return 1;
}
}
//park
if(strcmp(cmd,"/park",true)==0)
{
new vehicleid =  GetPlayerVehicleID(playerid);
if(pCarKey == 0) { SendClientMessage(playerid,COLOR_GRAD2," Nemas vlastito vozilo!"); return 1; }
if(IsPlayerConnected(playerid))
{
    for(new i = 0; i < sizeof(CarInfo); i++)
    {
    if(vehicleid == CarInfo)
    {
    new Float:x,Float:y,Float:z;
new Float:a;
GetVehiclePos(vehicleid, x, y, z);
GetVehicleZAngle(vehicleid, a);
CarInfo = x;
CarInfo = y;
CarInfo = z;
CarInfo = a;
}
}
}
SaveCars();
new Float:x;
new Float:y;
new Float:z;
new Float:a;
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);
new formatPARK;
format(formatPARK,sizeof(formatPARK),"Auto parkiran na kordinate X %d Y %d Z %d A %d",x,y,z,a);
SendClientMessage(playerid,COLOR_GREEN, formatPARK);
return 1;
}
return 0;
}
/*----------Car Save Functions----------*/
public LoadCar()
{
new arrCoords;
new strFromFile2;
new File: file = fopen("CarOwnership.cfg", io_read);
if (file)
{
new idx = 0;
while (idx < sizeof(CarInfo))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, ',');
CarInfo = strval(arrCoords);
CarInfo = floatstr(arrCoords);
CarInfo = floatstr(arrCoords);
CarInfo = floatstr(arrCoords);
CarInfo = floatstr(arrCoords);
CarInfo = strval(arrCoords);
CarInfo = strval(arrCoords);
strmid(CarInfo, arrCoords, 0, strlen(arrCoords), 255);
strmid(CarInfo, arrCoords, 0, strlen(arrCoords), 255);
CarInfo = strval(arrCoords);
CarInfo = strval(arrCoords);
CarInfo = strval(arrCoords);
CarInfo = strval(arrCoords);
printf("CarInfo: %d Owner:%s LicensePlate %s",idx,CarInfo,CarInfo);
idx++;
}
}
return 1;
}
public SaveCars()
{
new idx;
new File: file2;
while (idx < sizeof(CarInfo))
{
    new coordsstring;
format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%s,%d,%d\n",
CarInfo,
CarInfo,
CarInfo,
CarInfo,
CarInfo,
CarInfo,
CarInfo,
CarInfo,
CarInfo,
CarInfo,
CarInfo,
CarInfo,
CarInfo);
if(idx == 0)
{
file2 = fopen("CarOwnership.cfg", io_write);
}
else
{
file2 = fopen("CarOwnership.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
for(new i = 0; i < sizeof(CarInfo); i++)
{
    if(vehicleid == CarInfo)
    {
CarInfo = color1;
CarInfo = color2;
printf("CarOwnership report");
printf("** Car %s[%d] painted %d and %d",CarInfo,i,color1,color2);
}
}
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(IsPlayerConnected(playerid))
{
    for(new i = 0; i < sizeof(CarInfo); i++)
    {
    if(vehicleid == CarInfo)
    {
    new Float:x,Float:y,Float:z;
new Float:a;
GetVehiclePos(vehicleid, x, y, z);
GetVehicleZAngle(vehicleid, a);
CarInfo = x;
CarInfo = y;
CarInfo = z;
CarInfo = a;
}
if(CarAutolock == 1)
{
    for(new j = 0; j < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(j))
{
SetVehicleParamsForPlayer(vehicleid,j,0,1);
GameTextForPlayer(playerid,"~w~Car~n~~r~Autolocked",2500,3);
return 1;
}
}
}
}
}
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate==2)
{
    for(new i = 0; i < sizeof(CarInfo); i++)
    {
    new newcar = GetPlayerVehicleID(playerid);
    new string;
        if(newcar == CarInfo)
{
    if(CarInfo==0)
    {
        TogglePlayerControllable(playerid, 0);
        CarOffered=1;
        format(string,sizeof(string),"~w~Car: %s~n~Price: ~g~%d~n~~w~/carbuy to buy this car",CarInfo,CarInfo);
GameTextForPlayer(playerid,string,5000,5);
    }
}
}
}
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
if(cartrack!=0)
{
SendClientMessage(playerid,COLOR_YELLOW,"SMS: On-Star: Our sensors show that you have come within 5.0 metres of your vehicle");
DisablePlayerCheckpoint(playerid);
cartrack = 0;
}
return 1;
}
Ivex
4
Enforcer
6. Jul 2010.
Pa probaj umjesto
if(pCarKey == 0) { SendClientMessage(playerid,COLOR_GRAD2," Nemas vlastito vozilo!"); return 1; }


stavit
if(PlayerInfo == 0) { SendClientMessage(playerid,COLOR_GRAD2," Nemas vlastito vozilo!"); return 1; }
mariomako
5
Underboss
6. Jul 2010.
hvala resio sam

Morate biti prijavljeni da biste odgovorili na ovu temu.

Prijava

© 2026 SmartShark. All rights reserved.

Powered by Momentum|v2026.3.001 Alpha