Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Copyright by SporSeba97
- #define FILTERSCRIPT
- #include <a_samp>
- #include <dini>
- #define Rot 0xAA3333AA
- #define respawn_delay -1
- enum CInfo
- {
- Float:x,
- Float:y,
- Float:z,
- Float:angle,
- modelid,
- color1,
- color2,
- }
- new CarInfo[MAX_VEHICLES][CInfo];
- new CarAnzahl;
- forward Carsschreiben();
- forward Carslesen();
- new Farbe1[MAX_VEHICLES];
- new Farbe2[MAX_VEHICLES];
- new schreibversuche;
- new leseversuche;
- new wunschfarbe1[MAX_PLAYERS];
- new wunschfarbe2[MAX_PLAYERS];
- new CarID[MAX_VEHICLES];
- public Carsschreiben()
- {
- if(schreibversuche==3)
- {
- print("Schreiben nach 3. Versuch fehlgeschlagen!!");
- return 1;
- }
- new CarDatei[250];
- format(CarDatei,sizeof(CarDatei),"/Cars.ini");
- dini_IntSet(CarDatei,"Anzahl",CarAnzahl);
- if(dini_Exists(CarDatei))
- {
- for(new i = 0; i<=(CarAnzahl);i++)
- {
- new string[250];
- format(string,sizeof(string),"%i x",i);
- dini_FloatSet(CarDatei,string,CarInfo[i][x]);
- format(string,sizeof(string),"%i y",i);
- dini_FloatSet(CarDatei,string,CarInfo[i][y]);
- format(string,sizeof(string),"%i z",i);
- dini_FloatSet(CarDatei,string,CarInfo[i][z]);
- format(string,sizeof(string),"%i angle",i);
- dini_FloatSet(CarDatei,string,CarInfo[i][angle]);
- format(string,sizeof(string),"%i modelid",i);
- dini_IntSet(CarDatei,string,CarInfo[i][modelid]);
- format(string,sizeof(string),"%i color1",i);
- dini_IntSet(CarDatei,string,CarInfo[i][color1]);
- format(string,sizeof(string),"%i color2",i);
- dini_IntSet(CarDatei,string,CarInfo[i][color2]);
- }
- print("Cars in Datei gespeichert!!");
- schreibversuche=0;
- }
- else
- {
- print("Error: Datei nicht gefunden!!");
- print("Datei wird neu erstellt!!");
- dini_Create(CarDatei);
- print("Neuer Schreib versuch");
- schreibversuche++;
- Carsschreiben();
- }
- return 1;
- }
- public Carslesen()
- {
- if(leseversuche==3)
- {
- print("Schreiben nach 3. Versuch fehlgeschlagen!!");
- return 1;
- }
- new CarDatei[250];
- format(CarDatei,sizeof(CarDatei),"/Cars.ini");
- CarAnzahl=dini_Int(CarDatei,"Anzahl");
- if(dini_Exists(CarDatei))
- {
- for(new i = 0; i<=(CarAnzahl);i++)
- {
- new string[250];
- format(string,sizeof(string),"%i x",i);
- CarInfo[i][x]=dini_Float(CarDatei,string);
- format(string,sizeof(string),"%i y",i);
- CarInfo[i][y]=dini_Float(CarDatei,string);
- format(string,sizeof(string),"%i z",i);
- CarInfo[i][z]=dini_Float(CarDatei,string);
- format(string,sizeof(string),"%i angle",i);
- CarInfo[i][angle]=dini_Float(CarDatei,string);
- format(string,sizeof(string),"%i modelid",i);
- CarInfo[i][modelid]=dini_Int(CarDatei,string);
- format(string,sizeof(string),"%i color1",i);
- CarInfo[i][color1]=dini_Int(CarDatei,string);
- format(string,sizeof(string),"%i color2",i);
- CarInfo[i][color2]=dini_Int(CarDatei,string);
- CarID[i]=AddStaticVehicleEx(CarInfo[i][modelid],CarInfo[i][x],CarInfo[i][y],CarInfo[i][z],CarInfo[i][angle],CarInfo[i][color1],CarInfo[i][color2],respawn_delay);
- }
- print("Cars aus Datei gelesen");
- schreibversuche=0;
- }
- else
- {
- print("Error: Datei nicht gefunden!!");
- print("Datei wird neu erstellt!!");
- dini_Create(CarDatei);
- print("Neuer leseversuch");
- schreibversuche++;
- Carsschreiben();
- Carslesen();
- }
- return 1;
- }
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Dynamic Car System by SporSeba97");
- print("--------------------------------------\n");
- Carslesen();
- return 1;
- }
- public OnFilterScriptExit()
- {
- Carsschreiben();
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!IsPlayerConnected(playerid)) return 1;
- new idx;
- new cmd[250];
- cmd = strtok(cmdtext, idx);
- new tmp[250];
- if(strcmp(cmd,"/farbe",true)==0)
- {
- if(!IsPlayerAdmin(playerid))
- {
- SendClientMessage(playerid,Rot,"Du bist kein Admin!!");
- return 1;
- }
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, Rot, "Benutze /farbe [Farbe1][Farbe2]");
- return 1;
- }
- wunschfarbe1[playerid]=strval(tmp);
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, Rot, "Benutze /farbe [Farbe1][Farbe2]");
- return 1;
- }
- wunschfarbe2[playerid]=strval(tmp);
- new string[250];
- format(string, sizeof(string), "Farbe 1: %i Farbe 2: %i", wunschfarbe1[playerid],wunschfarbe2[playerid]);
- SendClientMessage(playerid, Rot, string);
- return 1;
- }
- if (strcmp(cmd,"/sveh",true) == 0)
- {
- if(!IsPlayerAdmin(playerid))
- {
- SendClientMessage(playerid,Rot,"Du bist kein Admin!!");
- return 1;
- }
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, Rot, "Benutze /sveh [modelid][Farbe1][Farbe2]");
- return 1;
- }
- new model;
- model=strval(tmp);
- tmp = strtok(cmdtext, idx);
- new cfarbe1;
- if(!strlen(tmp))
- {
- cfarbe1=wunschfarbe1[playerid];
- }
- else
- {
- cfarbe1=strval(tmp);
- }
- new cfarbe2;
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- cfarbe2=wunschfarbe2[playerid];
- }
- else
- {
- cfarbe2=strval(tmp);
- }
- if(model < 400 || model > 611)
- {
- SendClientMessage(playerid, Rot, " Du kannst nur ein Model zwischen 400 und 611 auswählen!!");
- return 1;
- }
- new Float:X,Float:Y,Float:Z;
- GetPlayerPos(playerid, X,Y,Z);
- new carid = AddStaticVehicleEx(model, X,Y,Z, 0.0, cfarbe1, cfarbe2, respawn_delay);
- Farbe1[carid]=cfarbe1;
- Farbe2[carid]=cfarbe2;
- PutPlayerInVehicle(playerid,carid,0);
- SendClientMessage(playerid,Rot,"Du hast ein neues Auto erzeugt!");
- return 1;
- }
- if(strcmp(cmd,"/speichern",true)==0)
- {
- new VID;
- VID=GetPlayerVehicleID(playerid);
- CarAnzahl++;
- CarInfo[CarAnzahl][modelid]=GetVehicleModel(VID);
- GetVehiclePos(VID,CarInfo[CarAnzahl][x],CarInfo[CarAnzahl][y],CarInfo[CarAnzahl][z]);
- GetVehicleZAngle(VID,CarInfo[CarAnzahl][angle]);
- CarInfo[CarAnzahl][color1]=Farbe1[VID];
- CarInfo[CarAnzahl][color2]=Farbe2[VID];
- return 1;
- }
- if(strcmp(cmd,"/getid",true)==0)
- {
- if(!IsPlayerAdmin(playerid))
- {
- SendClientMessage(playerid,Rot,"Du bist kein Admin!");
- return 1;
- }
- new ID = GetPlayerVehicleID(playerid);
- for(new i = 0;i<=CarAnzahl;i++)
- {
- if(CarID[i]==ID)
- {
- new string[250];
- format(string,sizeof(string),"Das Fahrzeug hat die ID %i",i);
- SendClientMessage(playerid,Rot,string);
- return 1;
- }
- }
- SendClientMessage(playerid,Rot,"Dieses Auto ist nicht registriert");
- return 1;
- }
- return 0;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- return 0;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement