Nem dolgoztam ki és nem is teszteltem. Ha hiba van írjátok és csinálom.
#include <a_samp>
#include <ZcMd>
#define P_X 747.7859
#define P_Y -543.5135
#define P_Z 15.8657
#define KI_X 740.9020
#define KI_Y -540.5073
#define KI_Z 16.3500
#define KI_ROT 0
new bool: Privat[MAX_VEHICLES];
new IdeigID[MAX_PLAYERS];
new Pickup;
new Mentes[MAX_VEHICLES][64 + 1];
new JarmuAdat[][] =
{
{400, 24999},
{401, 14999},
{404, 5999},
{405, 32999},
{410, 8999},
{422, 9999},
{426, 26999},
{436, 6999},
{445, 16999},
{462, 2999},
{468, 5999},
{475, 39999},
{478, 4999},
{527, 7999},
{529, 8999},
{536, 13999},
{543, 4999},
{566, 8999},
{576, 8999},
{585, 7999},
{605, 1299},
{604, 1299}
};
enum pAdat
{
Kocsi,
KocsiID
}
new pInfo[MAX_PLAYERS][pAdat];
enum vAdat
{
Float:xpos,
Float:ypos,
Float:zpos,
Float:rot,
model,
color1,
color2,
plate[32 + 1]
}
new vInfo[MAX_VEHICLES][vAdat];
stock create( playerid ) {
return fclose( fopen(plaFile(playerid), io_readwrite) ), 1;
}
stock LoadPlayerDAT( playerid ) {
new dest[2][8 + 1];
new string[32 + 1];
new File: pfile = fopen(plaFile(playerid), io_read);
if( pfile )
{
fread( pfile, string );
split( string, dest, \',\' );
}
pInfo[playerid][Kocsi] = strval(dest[0]);
pInfo[playerid][KocsiID] = strval(dest[1]);
return 1;
}
stock Save( playerid ) {
new File: pfile = fopen(plaFile(playerid));
if( pfile )
{
new pstring[32 + 1];
format( pstring, 32, \"%d,%d\", pInfo[playerid][Kocsi], pInfo[playerid][KocsiID] );
fwrite( pfile, pstring );
fclose( pfile );
}
return 1;
}
stock plaFile(playerid) {
new sz_pString[64 + 1];
format( sz_pString, 64, \"%s.dat\", playerName(playerid) );
return sz_pString;
}
stock playerName(playerid) {
new sz_pName[MAX_PLAYER_NAME + 1];
GetPlayerName(playerid, sz_pName, sizeof(sz_pName) );
return sz_pName;
}
public OnPlayerConnect( playerid ) {
if( fexist(plaFile(playerid)) ) {
LoadPlayerDAT( playerid );
}
else { create(playerid); }
return 1;
}
public OnPlayerDisconnect( playerid, reason ) {
#pragma unused reason
Save(playerid);
return 1;
}
public OnFilterScriptInit( )
{
printf( \"[Fl0rian] Jármû vásárlás - BETÖLTVE\" );
KocsikBetolt( );
Pickup = CreatePickup( 1239, 1, P_X, P_Y, P_Z );
return 1;
}
public OnFilterScriptExit( )
{
printf( \"[Fl0rian] Jármû vásárlás - LEÁLLÍTVA\" );
DestroyPickup( Pickup );
return 1;
}
public OnPlayerPickUpPickup( playerid, pickupid )
{
if( pickupid == Pickup )
{
if( pInfo[playerid][Kocsi] == 1 ) return SendClientMessage( playerid, 0xff0000AA, \"Neked már van autód!\" );
SetPlayerPos( playerid, P_X+1, P_Y+1, P_Z );
new dialText[512 + 1];
new tmp[64 + 1];
for( new i; i < sizeof JarmuAdat; i++ )
{
format( tmp, sizeof tmp, \"Jármû: %s | Ára: $%d\", GetVehicleModelName(JarmuAdat[0]), JarmuAdat[1] );
strins( dialText, tmp, strlen(dialText) );
format( Mentes, 64, \"%s\", GetVehicleModelName(JarmuAdat[0]) );
}
if( !strlen(dialText) ) return 1;
ShowPlayerDialog( playerid, 1, DIALOG_STYLE_LIST, \"Autó Szalon\", dialText, \"Tovább\", \"Kilépés\" );
}
return 1;
}
public OnPlayerStateChange( playerid, newstate, oldstate )
{
if( newstate == PLAYER_STATE_DRIVER )
{
if( GetPlayerVehicleID(playerid) != pInfo[playerid][KocsiID] )
{
RemovePlayerFromVehicle( playerid );
SendClientMessage( playerid, 0xff0000AA, \"Ez a jármû nem a tiéd!\" );
}
}
return 1;
}
public OnPlayerExitVehicle( playerid, vehicleid )
{
if( GetPlayerState(playerid) == PLAYER_STATE_DRIVER && vehicleid == pInfo[playerid][Kocsi] )
{
new vname[64 + 1];
format( vname, 64, \"%03d.dat\", vehicleid );
new File: vfile = fopen(vname);
#define LustaVagyok(%0) vInfo[pInfo[playerid][KocsiID]][%0]
if( vfile )
{
new vstring[128 + 1];
format( vstring, 128, \"%f,%f,%f,%f,%d,%d,%d,%s\", LustaVagyok(xpos), LustaVagyok(ypos), LustaVagyok(zpos), LustaVagyok(rot), LustaVagyok(color1), LustaVagyok(color2), LustaVagyok(model), LustaVagyok(plate) );
fwrite( vfile, vstring );
fclose( vfile );
}
}
return 1;
}
public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[] )
{
switch( dialogid )
{
case 1:
{
new veh;
if( GetPlayerMoney(playerid) < JarmuAdat[listitem][1] ) return SendClientMessage( playerid, 0xff0000AA, \"Nincs pénzed erre a jármûre!\" );
IdeigID[playerid] = GetVehicleIDFromName( Mentes[listitem] );
new rand1 = random(255);
new rand2 = random(255);
veh = CreateVehicle( IdeigID[playerid], KI_X, KI_Y, KI_Z, KI_ROT, rand1, rand2, 0 );
pInfo[playerid][Kocsi] = 1;
pInfo[playerid][KocsiID] = veh;
vInfo[veh][xpos] = KI_X;
vInfo[veh][ypos] = KI_Y;
vInfo[veh][zpos] = KI_Z;
vInfo[veh][rot] = KI_ROT;
vInfo[veh][color1] = rand1;
vInfo[veh][color2] = rand2;
vInfo[veh][model] = IdeigID[playerid];
Privat[veh] = true;
IdeigID[playerid] = -1;
new vname[64 + 1];
format( vname, 64, \"%03d.dat\", veh );
new File: vfile = fopen(vname);
#undef LustaVagyok
#define LustaVagyok(%0) vInfo[veh][%0]
if( vfile )
{
new vstring[128 + 1];
format( vstring, 128, \"%f,%f,%f,%f,%d,%d,%d,%s\", LustaVagyok(xpos), LustaVagyok(ypos), LustaVagyok(zpos), LustaVagyok(rot), LustaVagyok(color1), LustaVagyok(color2), LustaVagyok(model), LustaVagyok(plate) );
fwrite( vfile, vstring );
fclose( vfile );
}
SendClientMessage( playerid, 0x4a7affAA, \"Sikeresen megvetted a jármûvet!\" );
}
}
return 0;
}
CMD:stats(playerid, params[])
{
new str[128 + 1];
format( str, sizeof(str), \"Kocsi ID: %d\", pInfo[playerid][KocsiID] );
SendClientMessage( playerid, -1, str );
return 1;
}
CMD:parkol(playerid, params[])
{
if( !IsPlayerInAnyVehicle(playerid) ) return SendClientMessage( playerid, -1, \"Nem ülsz semmilyen jármûben\" ), 1;
OnPlayerExitVehicle( playerid, GetPlayerVehicleID(playerid) );
return 1;
}
stock KocsikBetolt()
{
new string[256 + 1];
new dest[8][64 + 1];
for( new veh = 0; veh < MAX_VEHICLES; veh++ )
{
new vname[64 + 1];
format( vname, 64, \"%03d.dat\", veh );
if( fexist(vname) )
{
new File: vfile = fopen(vname, io_read);
if( vfile )
{
fread( vfile, string );
split( string, dest, \',\' );
}
new vehi = CreateVehicle( strval(dest[6]), floatstr(dest[0]), floatstr(dest[1]), floatstr(dest[2]), floatstr(dest[3]), strval(dest[4]), strval(dest[5]), 0 );
SetVehicleNumberPlate( vehi, dest[7] );
vInfo[vehi][xpos] = floatstr(dest[0]);
vInfo[vehi][ypos] = floatstr(dest[1]);
vInfo[vehi][zpos] = floatstr(dest[2]);
vInfo[vehi][rot] = floatstr(dest[3]);
vInfo[vehi][color1] = strval(dest[4]);
vInfo[vehi][color2] = strval(dest[5]);
vInfo[vehi][model] = strval(dest[6]);
format( vInfo[vehi][plate], 32, \"%s\", dest[7] );
printf( \"ID: %d jármû betöltve.\", vehi );
}
}
return 1;
}
stock 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[aNum], strsrc, li, i, 128);
strdest[aNum][len] = 0;
li = i+1;
aNum++;
}
i++;
}
return 1;
}
new VehicleNames[212][] =
{
{\"Landstalker\"},{\"Bravura\"},{\"Buffalo\"},{\"Linerunner\"},{\"Perennial\"},{\"Sentinel\"},{\"Dumper\"}, {\"Firetruck\"},{\"Trashmaster\"},{\"Stretch\"},{\"Manana\"},{\"Infernus\"},{\"Voodoo\"},{\"Pony\"},{\"Mule\"}, {\"Cheetah\"},{\"Ambulance\"},{\"Leviathan\"},{\"Moonbeam\"},{\"Esperanto\"},{\"Taxi\"},{\"Washington\"}, {\"Bobcat\"},{\"Mr Whoopee\"},{\"BF Injection\"},{\"Hunter\"},{\"Premier\"},{\"Enforcer\"},{\"Securicar\"},
{\"Banshee\"},{\"Predator\"},{\"Bus\"},{\"Rhino\"},{\"Barracks\"},{\"Hotknife\"},{\"Trailer 1\"},{\"Previon\"}, {\"Coach\"},{\"Cabbie\"},{\"Stallion\"},{\"Rumpo\"},{\"RC Bandit\"},{\"Romero\"},{\"Packer\"},{\"Monster\"}, {\"Admiral\"},{\"Squalo\"},{\"Seasparrow\"},{\"Pizzaboy\"},{\"Tram\"},{\"Trailer 2\"},{\"Turismo\"}, {\"Speeder\"},{\"Reefer\"},{\"Tropic\"},{\"Flatbed\"},{\"Yankee\"},{\"Caddy\"},{\"Solair\"},{\"Berkley\'s RC Van\"},
{\"Skimmer\"},{\"PCJ-600\"},{\"Faggio\"},{\"Freeway\"},{\"RC Baron\"},{\"RC Raider\"},{\"Glendale\"},{\"Oceanic\"}, {\"Sanchez\"},{\"Sparrow\"},{\"Patriot\"},{\"Quad\"},{\"Coastguard\"},{\"Dinghy\"},{\"Hermes\"},{\"Sabre\"}, {\"Rustler\"},{\"ZR-350\"},{\"Walton\"},{\"Regina\"},{\"Comet\"},{\"BMX\"},{\"Burrito\"},{\"Camper\"},{\"Marquis\"}, {\"Baggage\"},{\"Dozer\"},{\"Maverick\"},{\"News Chopper\"},{\"Rancher\"},{\"FBI Rancher\"},{\"Virgo\"},{\"Greenwood\"},
{\"Jetmax\"},{\"Hotring\"},{\"Sandking\"},{\"Blista Compact\"},{\"Police Maverick\"},{\"Boxville\"},{\"Benson\"}, {\"Mesa\"},{\"RC Goblin\"},{\"Hotring Racer A\"},{\"Hotring Racer B\"},{\"Bloodring Banger\"},{\"Rancher\"}, {\"Super GT\"},{\"Elegant\"},{\"Journey\"},{\"Bike\"},{\"Mountain Bike\"},{\"Beagle\"},{\"Cropdust\"},{\"Stunt\"},
{\"Tanker\"}, {\"Roadtrain\"},{\"Nebula\"},{\"Majestic\"},{\"Buccaneer\"},{\"Shamal\"},{\"Hydra\"},{\"FCR-900\"}, {\"NRG-500\"},{\"HPV1000\"},{\"Cement Truck\"},{\"Tow Truck\"},{\"Fortune\"},{\"Cadrona\"},{\"FBI Truck\"}, {\"Willard\"},{\"Forklift\"},{\"Tractor\"},{\"Combine\"},{\"Feltzer\"},{\"Remington\"},{\"Slamvan\"},
{\"Blade\"},{\"Freight\"},{\"Streak\"},{\"Vortex\"},{\"Vincent\"},{\"Bullet\"},{\"Clover\"},{\"Sadler\"}, {\"Firetruck LA\"},{\"Hustler\"},{\"Intruder\"},{\"Primo\"},{\"Cargobob\"},{\"Tampa\"},{\"Sunrise\"},{\"Merit\"}, {\"Utility\"},{\"Nevada\"},{\"Yosemite\"},{\"Windsor\"},{\"Monster A\"},{\"Monster B\"},{\"Uranus\"},{\"Jester\"},
{\"Sultan\"},{\"Stratum\"},{\"Elegy\"},{\"Raindance\"},{\"RC Tiger\"},{\"Flash\"},{\"Tahoma\"},{\"Savanna\"}, {\"Bandito\"},{\"Freight Flat\"},{\"Streak Carriage\"},{\"Kart\"},{\"Mower\"},{\"Duneride\"},{\"Sweeper\"}, {\"Broadway\"},{\"Tornado\"},{\"AT-400\"},{\"DFT-30\"},{\"Huntley\"},{\"Stafford\"},{\"BF-400\"},{\"Newsvan\"}, {\"Tug\"},{\"Trailer 3\"},{\"Emperor\"},{\"Wayfarer\"},{\"Euros\"},{\"Hotdog\"},{\"Club\"},{\"Freight Carriage\"},
{\"Trailer 3\"},{\"Andromada\"},{\"Dodo\"},{\"RC Cam\"},{\"Launch\"},{\"Police Car (LSPD)\"},{\"Police Car (SFPD)\"}, {\"Police Car (LVPD)\"},{\"Police Ranger\"},{\"Picador\"},{\"S.W.A.T. Van\"},{\"Alpha\"},{\"Phoenix\"},{\"Glendale\"}, {\"Sadler\"},{\"Luggage Trailer A\"},{\"Luggage Trailer B\"},{\"Stair Trailer\"},{\"Boxville\"},{\"Farm Plow\"}, {\"Utility Trailer\"}
};
stock GetVehicleIDFromName( vehiclename[], type = 0 )
{
new integer = INVALID_VEHICLE_ID;
new talalat;
if( type == 0 )
{
for( new i = 0; i < 212; i++ )
{
if( strfind(VehicleNames[0], vehiclename, true ) != -1 )
{
integer = i + 400;
talalat++;
}
}
}
else
{
for( new i = 0; i < 212; i++ )
{
if( strcmp(VehicleNames[0], vehiclename, true ) == 0 )
{
integer = i + 400;
talalat++;
}
}
}
if( talalat > 1 )
{
printf( \"Több találat a következõre: \'%s\'\", vehiclename );
return INVALID_VEHICLE_ID;
}
if( talalat == 0 )
{
printf( \"Nincs találat a következõre: \'%s\'\", vehiclename );
}
return integer;
}
stock GetVehicleModelName( modell )
{
new STRING[64 + 1];
format( STRING, 64, \"%s\", VehicleNames[modell - 400][0] );
return STRING;
}