31.12.2010, 12:08
poa to com um FS de sistama de carros para comprar
mais eu nao sei onde ta os carrros !
mais quando eu vou mudar a posisao dos carros no arquivo CFG o carro nao vai
eu vo pego o carro poto no lugar pego as coordenadas boto na CFG mias o carro noa vai pro lugar ajuda ai
aki estб a FS:
arquivo CFG:
Ajuda aiiii !!!!
mais eu nao sei onde ta os carrros !
mais quando eu vou mudar a posisao dos carros no arquivo CFG o carro nao vai
eu vo pego o carro poto no lugar pego as coordenadas boto na CFG mias o carro noa vai pro lugar ajuda ai
aki estб a FS:
pawn Код:
//===========================Section: Includes==================================
#include <a_samp>
//===========================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[256][pInfo];
enum cInfo
{
cModel,
Float:cLocationx,
Float:cLocationy,
Float:cLocationz,
Float:cAngle,
cColorOne,
cColorTwo,
cOwner[MAX_PLAYER_NAME],
cDescription[MAX_PLAYER_NAME],
cValue,
cLicense,
cRegistration,
cOwned,
cLock,
ownedvehicle,
};
new CarInfo[12][cInfo];
new CarAutolock[999]; // Variable for Autolocking Car Doors
new cartrack[256];
new CarOffered[256];
//===========================Section: strtok & split============================
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
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[i]==delimiter || i==strlen(strsrc)){
len = strmid(strdest[aNum], strsrc, li, i, 128);
strdest[aNum][len] = 0;
li = i+1;
aNum++;
}
i++;
}
return 1;
}
//===========================Section: Callbacks & Functions=====================
public OnFilterScriptInit()
{
printf("Filterscript [FS]CarOwnership.amx Initiated\n");
LoadCar();
for(new i = 1; i < sizeof(CarInfo); i++)
{
CarInfo[i][ownedvehicle] = CreateVehicle(CarInfo[i][cModel],CarInfo[i][cLocationx],CarInfo[i][cLocationy],CarInfo[i][cLocationz],CarInfo[i][cAngle],CarInfo[i][cColorOne],CarInfo[i][cColorTwo],300000);
}
SetTimer("SaveCars",60000,1);
SetTimer("CheckOwner",5000,1);
return 1;
}
public OnVehicleSpawn(vehicleid)
{
for(new i = 1; i < sizeof(CarInfo); i++)
{
ChangeVehicleColor(CarInfo[i][ownedvehicle],CarInfo[vehicleid][cColorOne],CarInfo[vehicleid][cColorTwo]);
}
return 1;
}
public CheckOwner(playerid)
{
if(IsPlayerConnected(playerid))
{
for(new i = 1; i < sizeof(CarInfo); i++)
{
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
if(strcmp(playername,CarInfo[i][cOwner],true)==0)
{
PlayerInfo[i][pCarKey] = i;
return i;
}
}
}
return 1;
}
public OnPlayerConnect(playerid)
{
PlayerInfo[playerid][pCarKey] = 0;
CheckOwner(playerid);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new idx;
new string[256];
new cmd[256];
new tmp[256];
new sendername[MAX_PLAYER_NAME];
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[i][ownedvehicle] == vehid)
{
if(PlayerInfo[playerid][pCarKey]!=0)
{
SendClientMessage(playerid, COLOR_GREY, "Voзк Ja possui um carro use ,/carro vender para poder comprar outro!");
return 1;
}
if(CarInfo[i][cOwned]==1)
{
SendClientMessage(playerid, COLOR_GREY, "Este carro ja tem dono!");
return 1;
}
if(GetPlayerMoney(playerid) >= CarInfo[i][cValue])
{
PlayerInfo[playerid][pCarKey] = i;
CarInfo[i][cOwned] = 1;
CarOffered[playerid]=0;
GetPlayerName(playerid, sendername, sizeof(sendername));
strmid(CarInfo[i][cOwner], sendername, 0, strlen(sendername), 999);
GivePlayerMoney(playerid,-CarInfo[i][cValue]);
GameTextForPlayer(playerid, "~w~Parabens~n~Este carro й seu atй vendelo!", 5000, 3);
SendClientMessage(playerid, COLOR_GRAD2, "Parabens pelo seu novo carro!");
SendClientMessage(playerid, COLOR_GRAD2, "Digite /carro manual para ver o manual do carro!");
TogglePlayerControllable(playerid, 1);
SaveCars();
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, "Vocк nгo tem dinheiro suficiente!");
return 1;
}
}
}
}
return 1;
}
if(strcmp(cmd,"/carro",true)==0)
{
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid,COLOR_WHITE,"(( Use /carro manual para mais intruзхes do carro! ))");
return 1;
}
if(strcmp(tmp,"sair",true)==0)
{
CarOffered[playerid]=0;
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
return 1;
}
if(strcmp(tmp, "manual", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pCarKey]!=0)
{
format(string,sizeof(string),"________________%s________________",CarInfo[CheckOwner(playerid)][cDescription]);
SendClientMessage(playerid, COLOR_GREEN,string);
SendClientMessage(playerid, COLOR_GRAD2,"** /carro comprar - Comprar um carro");
SendClientMessage(playerid, COLOR_GRAD2,"** /carro vender - Vender o carro");
SendClientMessage(playerid, COLOR_GRAD2,"** /carro manual - Manual do carro");
SendClientMessage(playerid, COLOR_GRAD2,"** /carro sair - Sai do carro");
SendClientMessage(playerid, COLOR_GRAD2,"** /carro Localizar - Localiza onde estб o seu carro");
SendClientMessage(playerid, COLOR_GRAD2,"** /carro trancar - Tranca o carro");
SendClientMessage(playerid, COLOR_GRAD2,"** /carro destrancar - Destranca o carro");
SendClientMessage(playerid, COLOR_GRAD2,"** /carro autotrancar - Bloqueia automaticamente o carro ao sair");
return 1;
}
else
{
SendClientMessage(playerid,COLOR_GRAD2,"** Vocк nгo possui atualmente um carro! **");
return 1;
}
}
return 1;
}
if(strcmp(tmp, "comprar", true) == 0)
{
if(IsPlayerConnected(playerid))
{
for(new i = 0; i < sizeof(CarInfo); i++)
{
if(CarInfo[i][ownedvehicle] == vehid)
{
if(PlayerInfo[playerid][pCarKey]!=0)
{
SendClientMessage(playerid, COLOR_GREY, "Voзк Ja possui um carro use ,/carro vender para poder comprar outro!");
return 1;
}
if(CarInfo[i][cOwned]==1)
{
SendClientMessage(playerid, COLOR_GREY, "Este carro ja tem dono!");
return 1;
}
if(GetPlayerMoney(playerid) >= CarInfo[i][cValue])
{
PlayerInfo[playerid][pCarKey] = i;
CarInfo[i][cOwned] = 1;
CarOffered[playerid]=0;
GetPlayerName(playerid, sendername, sizeof(sendername));
strmid(CarInfo[i][cOwner], sendername, 0, strlen(sendername), 999);
GivePlayerMoney(playerid,-CarInfo[i][cValue]);
GameTextForPlayer(playerid, "~w~Parabens~n~Este carro agora й seu atй vendelo!", 5000, 3);
SendClientMessage(playerid, COLOR_GRAD2, "Parabens pelo seu novo carro!");
SendClientMessage(playerid, COLOR_GRAD2, "Digite /carro manual para ver o manual do carro!");
TogglePlayerControllable(playerid, 1);
SaveCars();
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, "Vocк nгo tem dinheiro suficiente!");
return 1;
}
}
}
}
return 1;
}
if(strcmp(tmp, "vender", true) == 0)
{
if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, playername, sizeof(playername));
if(PlayerInfo[playerid][pCarKey] == 0)
{
SendClientMessage(playerid, COLOR_GREY, "Voзк nгo tem um carro");
return 1;
}
if(PlayerInfo[playerid][pCarKey] != 0 && strcmp(playername, CarInfo[PlayerInfo[playerid][pCarKey]][cOwner], true) == 0)
{
new car = PlayerInfo[playerid][pCarKey];
CarInfo[car][cOwned] = 0;
GetPlayerName(playerid, sendername, sizeof(sendername));
strmid(CarInfo[car][cOwner], "Dealership", 0, strlen("Dealership"), 999);
GivePlayerMoney(playerid,CarInfo[car][cValue]);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
format(string, sizeof(string), "~w~Vocк vendeu seu carro para: ~n~~g~$%d", CarInfo[car][cValue]);
GameTextForPlayer(playerid, string, 10000, 3);
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
PlayerInfo[playerid][pCarKey] = 999;
return 1;
}
}
return 1;
}
if(strcmp(tmp, "localizar", true) == 0)
{
if(!IsPlayerConnected(playerid)) { return 1; }
if(PlayerInfo[playerid][pCarKey] == 0) { GameTextForPlayer(playerid, "~w~Vocк nгo tem um carro para localizar", 2500, 3); return 1; }
if(cartrack[playerid]==0)
{
SendClientMessage(playerid,COLOR_WHITE,"On-Star: Isto й On-Star sistema de rastreamento automбtico de veнculos");
SendClientMessage(playerid,COLOR_WHITE,"On-Star: Insira o seu PIN e senha agora #");
SendClientMessage(playerid,COLOR_WHITE,"On-Star: A localizaзгo do seu veнculo foi enviado para o seu telefone");
SetPlayerCheckpoint(playerid,CarInfo[PlayerInfo[playerid][pCarKey]][cLocationx], CarInfo[PlayerInfo[playerid][pCarKey]][cLocationy], CarInfo[PlayerInfo[playerid][pCarKey]][cLocationz], 5.0);
cartrack[playerid] = 1;
return 1;
}
else
{
SendClientMessage(playerid,COLOR_WHITE,"On-Star: Isto й On-Star sistema de rastreamento automбtico de veнculos");
SendClientMessage(playerid,COLOR_WHITE,"On-Star: O rastreamento do seu veнculo foi cancelado");
DisablePlayerCheckpoint(playerid);
cartrack[playerid] = 0;
return 1;
}
}
if(strcmp(tmp, "trancar", true) == 0)
{
new keycar = PlayerInfo[playerid][pCarKey];
if(IsPlayerConnected(playerid))
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
SetVehicleParamsForPlayer(CarInfo[keycar][ownedvehicle],i,0,1);
}
format(string, sizeof(string), "~w~Carro~n~~r~Trancado");
GameTextForPlayer(playerid, string, 10000, 3);
CarInfo[keycar][cLock] = 1;
return 1;
}
}
if(strcmp(tmp, "destrancar", true) == 0)
{
new keycar = PlayerInfo[playerid][pCarKey];
if(IsPlayerConnected(playerid))
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
SetVehicleParamsForPlayer(CarInfo[keycar][ownedvehicle],i,0,0);
}
format(string, sizeof(string), "~w~Carro~n~~g~Destrancado");
GameTextForPlayer(playerid, string, 10000, 3);
CarInfo[keycar][cLock] = 0;
return 1;
}
}
if(strcmp(tmp, "autotrancar", true) == 0)
{
new keycar = PlayerInfo[playerid][pCarKey];
if(CarAutolock[CarInfo[keycar][ownedvehicle]] == 0) { CarAutolock[CarInfo[keycar][ownedvehicle]] = 1; format(string, sizeof(string), "~w~Carro Trancado~n~~r~Automaticamente"); return 1; }
if(CarAutolock[CarInfo[keycar][ownedvehicle]] == 1) { CarAutolock[CarInfo[keycar][ownedvehicle]] = 0; format(string, sizeof(string), "~w~Carro Destrancado~n~~g~Automaticamente"); return 1; }
GameTextForPlayer(playerid, string, 10000, 3);
return 1;
}
}
return 0;
}
/*----------Car Save Functions----------*/
public LoadCar()
{
new arrCoords[13][64];
new strFromFile2[256];
new File: file = fopen("[FS]CarOwnership.cfg", io_read);
if (file)
{
new idx = 0;
while (idx < sizeof(CarInfo))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, ',');
CarInfo[idx][cModel] = strval(arrCoords[0]);
CarInfo[idx][cLocationx] = floatstr(arrCoords[1]);
CarInfo[idx][cLocationy] = floatstr(arrCoords[2]);
CarInfo[idx][cLocationz] = floatstr(arrCoords[3]);
CarInfo[idx][cAngle] = floatstr(arrCoords[4]);
CarInfo[idx][cColorOne] = strval(arrCoords[5]);
CarInfo[idx][cColorTwo] = strval(arrCoords[6]);
strmid(CarInfo[idx][cOwner], arrCoords[7], 0, strlen(arrCoords[7]), 255);
strmid(CarInfo[idx][cDescription], arrCoords[8], 0, strlen(arrCoords[8]), 255);
CarInfo[idx][cValue] = strval(arrCoords[9]);
CarInfo[idx][cLicense] = strval(arrCoords[10]);
CarInfo[idx][cOwned] = strval(arrCoords[11]);
CarInfo[idx][cLock] = strval(arrCoords[12]);
printf("CarroInfo: %d Proprietбrio:%s Placa de Licenзa: %s",idx,CarInfo[idx][cOwner],CarInfo[idx][cLicense]);
idx++;
}
}
return 1;
}
public SaveCars()
{
new idx;
new File: file2;
while (idx < sizeof(CarInfo))
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%s,%d,%d\n",
CarInfo[idx][cModel],
CarInfo[idx][cLocationx],
CarInfo[idx][cLocationy],
CarInfo[idx][cLocationz],
CarInfo[idx][cAngle],
CarInfo[idx][cColorOne],
CarInfo[idx][cColorTwo],
CarInfo[idx][cOwner],
CarInfo[idx][cDescription],
CarInfo[idx][cValue],
CarInfo[idx][cLicense],
CarInfo[idx][cOwned],
CarInfo[idx][cLock]);
if(idx == 0)
{
file2 = fopen("[FS]CarOwnership.cfg", io_write);
}
else
{
file2 = fopen("[FS]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[i][ownedvehicle])
{
CarInfo[i][cColorOne] = color1;
CarInfo[i][cColorTwo] = color2;
printf("[FS]CarOwnership report");
printf("** Carro %s[%d] Pintado %d e %d",CarInfo[i][cDescription],i,color1,color2);
}
}
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(IsPlayerConnected(playerid))
{
for(new i = 0; i < sizeof(CarInfo); i++)
{
if(vehicleid == CarInfo[i][ownedvehicle])
{
new Float:x,Float:y,Float:z;
new Float:a;
GetVehiclePos(vehicleid, x, y, z);
GetVehicleZAngle(vehicleid, a);
CarInfo[i][cLocationx] = x;
CarInfo[i][cLocationy] = y;
CarInfo[i][cLocationz] = z;
CarInfo[i][cAngle] = a;
}
if(CarAutolock[vehicleid] == 1)
{
for(new j = 0; j < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(j))
{
SetVehicleParamsForPlayer(vehicleid,j,0,1);
GameTextForPlayer(playerid,"~w~Carro~n~~r~Localizado",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[256];
if(newcar == CarInfo[i][ownedvehicle])
{
if(CarInfo[i][cOwned]==0)
{
TogglePlayerControllable(playerid, 0);
CarOffered[playerid]=1;
format(string,sizeof(string),"~w~Carro: %s~n~Preзo: ~g~%d~n~~w~/carro comprar para comprar este carro",CarInfo[i][cDescription],CarInfo[i][cValue]);
GameTextForPlayer(playerid,string,5000,5);
}
}
}
}
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
if(cartrack[playerid]!=0)
{
SendClientMessage(playerid,COLOR_YELLOW,"SMS: On-Star: Nossos sensores mostram que vocк veio dentro de 5,0 metros de seu veнculo");
DisablePlayerCheckpoint(playerid);
cartrack[playerid] = 0;
}
return 1;
}
Код:
422,2135.418701,-1128.477294,25.593200,110.959999,1,1,Dealership,Bobcat,50000,,0,0 543,2136.328613,-1132.250976,25.511566,110.258712,1,1,Dealership,Sadler,50000,,0,0 554,2135.458496,-1136.625488,25.735660,107.892265,1,1,Dealership,Yosemite,50000,,0,0 579,2135.744140,-1140.979614,25.173116,111.251762,1,1,Dealership,Huntley,50000,,0,0 400,2136.281738,-1144.528686,24.955900,109.024398,1,1,Dealership,Landstalker,50000,,0,0 500,2136.882568,-1147.977294,24.593900,104.355201,1,1,Dealership,Mesa,50000,,0,0 489,2122.037597,-1157.092285,24.256799,356.001007,1,1,Dealership,Rancher,50000,,0,0 445,2117.238281,-1156.901367,24.194599,337.440185,1,1,Dealership,Admiral,50000,,0,0 492,2117.775146,-1148.868041,24.202800,331.458801,1,1,Dealership,Greenwood,50000,,0,0 410,2117.998535,-1141.823730,24.537799,325.724914,1,1,Dealership,Manana,50000,,0,0 600,2118.116210,-1135.639526,24.913400,326.202606,1,1,Dealership,Picador,50000,,0,0 496,2118.714111,-1129.351440,25.015199,318.569488,1,1,Dealership,Blista Compact,50000,,0,0