stock CheckRpName(const name[]) {
new length=strlen(name),
ch;
for(ch=0; ch<length; ch++) if(name[ch]) break;
if(ch==(length+1)) return false;
for(ch=0; ch<length; ch++) {
if((ch>=2) && (ch<=(length-2))) {
if((name[ch]>=\'a\')&&(name[ch]<=\'z\')||(name[ch]>=\'A\')&&(name[ch]<=\'Z\')||name[ch]==\'_\') {}
else return false;
}
else {
if(name[ch]==\'_\') return false;
}
}
return true;
}
stock nev(id)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(id,name,sizeof(name));
return name;
}
stock msg(id,uzi[])
{
SendClientMessage(id,feher,uzi);
}
stock nullazas(id)
{
lepve[id] = 0;
pi[id][admin] = 0;
pi[id][ban] = 0;
pi[id][as] = 0;
pi[id][vip] = 0;
rpw[id] = 0;
}
stock save(id)
{
new
Float: g_fHealth;
new fajl[128];
GetPlayerHealth(id,g_fHealth);
format(fajl,sizeof(fajl),\"/admin/%s.ini\",nev(id));
if(fexist(fajl))
{
dini_IntSet(fajl,\"admin\", pi[id][admin]);
dini_IntSet(fajl,\"frakcio\", pi[id][pMember]);
dini_IntSet(fajl,\"leader\", pi[id][pLeader]);
dini_IntSet(fajl,\"ban\", pi[id][ban]);
dini_IntSet(fajl,\"as\", pi[id][as]);
dini_IntSet(fajl,\"vip\", pi[id][vip]);
dini_Set(fajl,\"aname\", pi[id][aname]);
dini_IntSet(fajl,\"penz\",GetPlayerMoney(id));
dini_IntSet(fajl,\"pont\",GetPlayerScore(id));
dini_IntSet(fajl,\"korozes\",GetPlayerWantedLevel(id));
dini_FloatSet( fajl, \"elet\",g_fHealth);
}
}
stock load(id)
{
new fajl[128];
format(fajl,sizeof(fajl),\"/admin/%s.ini\",nev(id));
if(fexist(fajl))
{
pi[id][admin] = dini_Int(fajl,\"admin\");
pi[id][pMember] = dini_Int(fajl,\"frakcio\");
pi[id][pLeader] = dini_Int(fajl,\"leader\");
pi[id][ban] = dini_Int(fajl,\"ban\");
pi[id][as] = dini_Int(fajl,\"as\");
pi[id][vip] = dini_Int(fajl,\"vip\");
GivePlayerMoney(id,dini_Int(fajl,\"penz\"));
SetPlayerScore(id,dini_Int(fajl,\"pont\"));
SetPlayerWantedLevel(id,dini_Int(fajl,\"korozes\"));
SetPlayerHealth(id,dini_Int(fajl,\"elet\"));
format(pi[id][aname],24,\"%s\",dini_Get(fajl,\"aname\"));
}
}
stock StripNewLinee(string[])
{
new len = strlen(string); // Get the length of the given string
if (string[0] == 0) return ; // If the given string is empty, exit the function
if ((string[len - 1] == \'\\n\') || (string[len - 1] == \'\\r\')) // If the string ends with \\n or \\r
{
string[len - 1] = 0; // Replace the \\n or \\r with a 0 character
if (string[0]==0) return ; // If the string became empty, exit the function
if ((string[len - 2] == \'\\n\') || (string[len - 2] == \'\\r\')) // Check again if the string ends with \\n or \\r
string[len - 2] = 0; // Replace the \\n or \\r again with a 0 character
}
}
stock IsVehicleOccupied (vehicleid)
{
new i;
while(i < MAX_PLAYERS)
{
if ( IsPlayerInVehicle ( i, vehicleid ) ) return 1;
i++;
}
return 0;
}
stock p_Name(playerid)
{
new
name[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, name, MAX_PLAYER_NAME );
return name;
}
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ármu 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övetkezore: \'%s\'\", vehiclename );
return INVALID_VEHICLE_ID;
}
if( talalat == 0 )
{
printf( \"Nincs találat a következore: \'%s\'\", vehiclename );
}
return integer;
}
stock GetVehicleModelName( modell )
{
new STRING[64 + 1];
format( STRING, 64, \"%s\", VehicleNames[modell - 400][0] );
return STRING;
}
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;
}
stock UnderscoreToSpaceName(playerid)
{
new Name0[MAX_PLAYER_NAME];
if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, Name0, sizeof(Name0));
}
else
{
Name0 = \"Disconnected/Nothing\";
}
for(new name0 = 0; name0 < MAX_PLAYER_NAME; name0++) if(Name0[name0] == \'_\') Name0[name0] = \' \';
return Name0;
}
stock IsRPName(const name[], max_underscores = 2)
{
new underscores = 0;
if (name[0] < \'A\' || name[0] > \'Z\') return false;
for(new i = 1; i < strlen(name); i++)
{
if(name != \'_\' && (name < \'A\' || name > \'Z\') && (name < \'a\' || name > \'z\')) return false; // a-zA-Z_
if( (name >= \'A\' && name <= \'Z\') && (name[i - 1] != \'_\') ) return false; // indokolatlan nagybetû használata
if(name == \'_\')
{
underscores++;
if(underscores > max_underscores || i == strlen(name)) return false; // Több aláhúzás mint a max, vagy aláhúzás az utolsó karakteren
if(name[i + 1] < \'A\' || name[i + 1] > \'Z\') return false; // Aláhúzás után nem nagybetû következik
}
}
if (underscores == 0) return false; // Nincs benne aláhúzásjel
return true;
}