Advertisement
Guest User

Filterscript - Fraktionscars

a guest
Aug 14th, 2012
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 29.53 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define Fraction_Need_Adminlevel 1337
  4. #define Fraction_Car_File "Fractioncars.cfg"
  5. #define MAX_FRACTION_CARS 500
  6. #define MAX_FRACTIONS 20
  7.  
  8. #define fDialog_Vehid 3333
  9. #define fDialog_Col1 3334
  10. #define fDialog_Col2 3335
  11. #define fDialog_Fraction1 3336
  12. #define fDialog_Fraction2 3337
  13. #define fDialog_Fraction3 3338
  14. #define fDialog_Fraction4 3339
  15. #define fDialog_Fraction5 3340
  16. #define fDialog_Create 3341
  17.  
  18. #define fColGrey 0xAFAFAFAA
  19. #define fColYellow 0xFFFF00FF
  20.  
  21. new fCarName[][] =
  22. {
  23.     "Landstalker","Bravura","Buffalo", "Linerunner", "Perrenial", "Sentinel",
  24.     "Dumper","Firetruck","Trashmaster", "Stretch", "Manana", "Infernus",
  25.     "Voodoo","Pony","Mule","Cheetah", "Ambulance", "Leviathan", "Moonbeam",
  26.     "Esperanto","Taxi","Washington", "Bobcat", "Whoopee", "BF Injection",
  27.     "Hunter","Premier","Enforcer", "Securicar", "Banshee", "Predator", "Bus",
  28.     "Rhino","Barracks","Hotknife", "Trailer", "Previon", "Coach", "Cabbie",
  29.     "Stallion","Rumpo","RC Bandit", "Romero", "Packer", "Monster", "Admiral",
  30.     "Squalo","Seasparrow","Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder",
  31.     "Reefer","Tropic","Flatbed", "Yankee", "Caddy", "Solair", "Berkley's RC Van",
  32.     "Skimmer","PCJ-600","Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale",
  33.     "Oceanic","Sanchez","Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy",
  34.     "Hermes","Sabre","Rustler", "ZR-350", "Walton", "Regina", "Comet", "BMX",
  35.     "Burrito","Camper","Marquis", "Baggage", "Dozer", "Maverick", "News Chopper",
  36.     "Rancher","FBI Rancher","Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking",
  37.     "Blista Compact","Police Maverick", "Boxvillde", "Benson", "Mesa", "RC Goblin",
  38.     "Hotring Racer A","Hotring Racer B", "Bloodring Banger", "Rancher", "Super GT",
  39.     "Elegant","Journey","Bike", "Mountain Bike", "Beagle", "Cropduster", "Stunt",
  40.     "Tanker","Roadtrain","Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra",
  41.     "FCR-900","NRG-500","HPV1000", "Cement Truck", "Tow Truck", "Fortune",
  42.     "Cadrona","FBI Truck","Willard", "Forklift", "Tractor", "Combine", "Feltzer",
  43.     "Remington","Slamvan","Blade", "Freight", "Streak", "Vortex", "Vincent",
  44.     "Bullet","Clover","Sadler", "Firetruck", "Hustler", "Intruder", "Primo",
  45.     "Cargobob","Tampa","Sunrise", "Merit", "Utility", "Nevada", "Yosemite",
  46.     "Windsor","Monster","Monster", "Uranus", "Jester", "Sultan", "Stratum",
  47.     "Elegy","Raindance","RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito",
  48.     "Freight Flat","Streak Carriage", "Kart", "Mower", "Dune", "Sweeper",
  49.     "Broadway","Tornado","AT-400", "DFT-30", "Huntley", "Stafford", "BF-400",
  50.     "News Van","Tug","Trailer","Emperor", "Wayfarer", "Euros", "Hotdog", "Club",
  51.     "Freight Box","Trailer", "Andromada","Dodo", "RC Cam", "Launch", "Police Car",
  52.     "Police Car","Police Car", "Police Ranger", "Picador", "S.W.A.T", "Alpha",
  53.     "Phoenix","2. Gebrauchtwagen","1. Gebrauchtwagen", "Luggage", "Luggage", "Stairs", "Boxville",
  54.     "Tiller","Utility Trailer"
  55. };
  56.  
  57. enum fInfo
  58. {
  59.     bool:fLock,
  60.     fCarid,
  61.     fVehid,
  62.     Float:fPos[4],
  63.     fCol[2],
  64.     fFraction[5]
  65. };
  66. new FractionCars[MAX_FRACTION_CARS][fInfo];
  67. new FractionTimer;
  68.  
  69. forward LoadFractionCars();
  70. forward SaveFractionCars();
  71. forward fUnlockCar(Carid);
  72. forward fLockCar(Carid);
  73. forward RemoveFromCar(playerid);
  74. forward DestroyAndCreateFractionCar(fc);
  75. forward FractionLockDoors();
  76.  
  77. public OnFilterScriptInit(){
  78.     LoadFractionCars();
  79.     FractionTimer=SetTimer("FractionLockDoors",1000,true);
  80.     return 1;
  81. }
  82.  
  83. public OnFilterScriptExit(){
  84.     SaveFractionCars();
  85.     KillTimer(FractionTimer);
  86.     return 1;
  87. }
  88.  
  89. public OnVehicleDeath(vehicleid, killerid){
  90.     new fc;while(fc<MAX_FRACTION_CARS){
  91.         if(FractionCars[fc][fVehid] >= 400 && FractionCars[fc][fVehid] <= 611){
  92.             if(FractionCars[fc][fCarid] == vehicleid){
  93.                 SetTimerEx("DestroyAndCreateFractionCar",3000,0,"d",fc);
  94.                 break;
  95.             }
  96.         }fc++;
  97.     }return 1;
  98. }
  99.  
  100. public OnPlayerCommandText(playerid, cmdtext[]){
  101.     if(strcmp(cmdtext,"/efa",true)==0){
  102.         if(PlayerAdministrator(playerid) >= Fraction_Need_Adminlevel){
  103.             return ShowPlayerDialog(playerid,fDialog_Vehid,DIALOG_STYLE_INPUT,"Fraktionsfahrzeug erstellen:","Bitte gebe die Vehicle-ID des Fahrzeuges an, das du erstellen möchtest:","Weiter","Abbrechen");
  104.         }return SendClientMessage(playerid,fColGrey,"Du bist nicht berechtigt diesen Befehl auszuführen.");
  105.     }
  106.     if(strcmp(cmdtext,"/lfa",true)==0){
  107.         if(PlayerAdministrator(playerid) >= Fraction_Need_Adminlevel){
  108.             new fc; while(fc<MAX_FRACTION_CARS){
  109.                 if(FractionCars[fc][fVehid] >= 400 && FractionCars[fc][fVehid] <= 611){
  110.                     new Float:fX,Float:fY,Float:fZ;
  111.                     GetVehiclePos(FractionCars[fc][fCarid],fX,fY,fZ);
  112.                     if(IsPlayerInRangeOfPoint(playerid,5.0,fX,fY,fZ)){
  113.                         FractionCars[fc][fVehid]=-255;
  114.                         if(fUnlockCar(FractionCars[fc][fCarid]))
  115.                             FractionCars[fc][fLock] = false;
  116.                         if(DestroyVehicle(FractionCars[fc][fCarid]))
  117.                             FractionCars[fc][fCarid] = -255;
  118.                         new Text[256];
  119.                         format(Text,sizeof(Text),">> Du hast das Fraktionsfahrzeug der Fraktion '%d' entfernt.",FractionCars[fc][fFraction][0]);
  120.                         return SendClientMessage(playerid,fColYellow,Text);
  121.                     }
  122.                 }fc++;
  123.             }return SendClientMessage(playerid,fColGrey,"Du bist nicht in der Nähe eines Fraktionsfahrzeuges.");
  124.         }return SendClientMessage(playerid,fColGrey,"Du bist nicht berechtigt diesen Befehl auszuführen.");
  125.     }
  126.     if(strcmp(cmdtext,"/flock",true)==0){
  127.         if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER){
  128.             new Carid=GetPlayerVehicleID(playerid);
  129.             new fc;while(fc<MAX_FRACTION_CARS){
  130.                 if(FractionCars[fc][fVehid] >= 400 && FractionCars[fc][fVehid] <= 611){
  131.                     if(FractionCars[fc][fCarid] == Carid){
  132.                         for(new f;f<5;f++){
  133.                             if(PlayerFraction(playerid) == FractionCars[fc][fFraction][f]){
  134.                                 if(FractionCars[fc][fLock]){
  135.                                     FractionCars[fc][fLock]=false;
  136.                                     fUnlockCar(FractionCars[fc][fCarid]);
  137.                                     GameTextForPlayer(playerid,"~w~Fahrzeug~n~~g~Aufgeschlossen",5000,3);
  138.                                     return true;
  139.                                 }
  140.                                 if(!FractionCars[fc][fLock]){
  141.                                     fLockCar(FractionCars[fc][fCarid]);
  142.                                     FractionCars[fc][fLock]=true;
  143.                                     GameTextForPlayer(playerid,"~w~Fahrzeug~n~~r~Abgeschlossen",5000,3);
  144.                                     return true;
  145.                                 }
  146.                             }
  147.                         }
  148.                     }
  149.                 }fc++;
  150.             }
  151.         }else{
  152.             if(GetPlayerState(playerid)==PLAYER_STATE_PASSENGER)
  153.                 return SendClientMessage(playerid,fColGrey,"Du musst der Fahrer dieses Fahrzeuges sein.");
  154.             return SendClientMessage(playerid,fColGrey,"Du muss in einem Fahrzeug sitzen.");
  155.         }return SendClientMessage(playerid,fColGrey,"Du sitzt in keinem Fraktionsfahrzeug!");
  156.     }
  157.     if(strcmp(cmdtext,"/fpark",true)==0){
  158.         if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER){
  159.             new fc;while(fc<MAX_FRACTION_CARS){
  160.                 if(FractionCars[fc][fVehid] >= 400 && FractionCars[fc][fVehid] <= 611){
  161.                     if(GetPlayerVehicleID(playerid) == FractionCars[fc][fCarid]){
  162.                         if(PlayerAdministrator(playerid) >= Fraction_Need_Adminlevel || PlayerLeader(playerid) == FractionCars[fc][fFraction][0]){
  163.                             new Float:fX,Float:fY,Float:fZ,Float:fA;
  164.                             GetVehiclePos(FractionCars[fc][fCarid],fX,fY,fZ),GetVehicleZAngle(FractionCars[fc][fCarid],fA);
  165.                             FractionCars[fc][fPos][0]=fX;
  166.                             FractionCars[fc][fPos][1]=fY;
  167.                             FractionCars[fc][fPos][2]=fZ;
  168.                             FractionCars[fc][fPos][3]=fA;
  169.                             return SendClientMessage(playerid,fColYellow,">> Du hast das Fraktionsfahrzeug erfolgreich umgeparkt.");
  170.                         }else { return SendClientMessage(playerid,fColGrey,"Du bist dazu nicht berechtigt."); }
  171.                     }
  172.                 }fc++;
  173.             }return SendClientMessage(playerid,fColGrey,"Du sitzt in keinem Fraktionsfahrzeug.");
  174.         }return SendClientMessage(playerid,fColGrey,"Du sitzt in keinem Fahrzeug oder bist nicht der Fahrer.");
  175.     }
  176.     if(strcmp(cmdtext,"/rfc",true)==0){
  177.         if(PlayerLeader(playerid)){
  178.             new fc;while(fc<MAX_FRACTION_CARS){
  179.                 if(FractionCars[fc][fVehid] >= 400 && FractionCars[fc][fVehid] <= 611){
  180.                     if(FractionCars[fc][fFraction][0] == PlayerLeader(playerid)){
  181.                         DestroyAndCreateFractionCar(fc);
  182.                     }
  183.                 }fc++;
  184.             }return SendClientMessage(playerid,fColYellow,">> Du hast deine Fraktionsfahrzeuge respawnt.");
  185.         }return SendClientMessage(playerid,fColGrey,"Du bist nicht berechtigt diesen Befehl auszuführen.");
  186.     }
  187.     if(strcmp(cmdtext,"/rafc",true)==0){
  188.         if(PlayerAdministrator(playerid) >= Fraction_Need_Adminlevel){
  189.             new fc;while(fc<MAX_FRACTION_CARS){
  190.                 if(FractionCars[fc][fVehid] >= 400 && FractionCars[fc][fVehid] <= 611){
  191.                     DestroyAndCreateFractionCar(fc);
  192.                 }fc++;
  193.             }return SendClientMessage(playerid,fColYellow,">> Du hast alle Fraktionsfahzeuge respawnt!");
  194.         }return SendClientMessage(playerid,fColGrey,"Du bist nicht berechtigt diesen Befehl auszuführen.");
  195.     }
  196.     return 0;
  197. }
  198.  
  199. public OnPlayerStateChange(playerid, newstate, oldstate){
  200.     if(newstate==PLAYER_STATE_DRIVER){
  201.         new Carid=GetPlayerVehicleID(playerid);
  202.         new fc;while(fc<MAX_FRACTION_CARS){
  203.             if(FractionCars[fc][fVehid] >= 400 && FractionCars[fc][fVehid] <= 611){
  204.                 if(FractionCars[fc][fCarid] == Carid){
  205.                     for(new f;f<5;f++){
  206.                         if(PlayerAdministrator(playerid) >= Fraction_Need_Adminlevel || PlayerFraction(playerid) == FractionCars[fc][fFraction][f])
  207.                             return true;
  208.                     }
  209.                     SendClientMessage(playerid,fColGrey,"Du bestitzt für dieses Fahrzeug keine Schlüssel, du verlässt das Fahrzeug.");
  210.                     RemovePlayerFromVehicle(playerid);
  211.                     SetTimerEx("RemoveFromCar",2500,false,"i",playerid);
  212.                     return true;
  213.                 }
  214.             }fc++;
  215.         }
  216.     }return 1;
  217. }
  218.  
  219. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
  220.     if(dialogid==fDialog_Vehid){
  221.         if(!response) return SendClientMessage(playerid,fColGrey,"Du hast den Vorgang abgebrochen.");
  222.         if(strval(inputtext) >= 400 && strval(inputtext) <= 611){
  223.             SetPVarInt(playerid,"fVehid",strval(inputtext));
  224.             return ShowPlayerDialog(playerid,fDialog_Col1,DIALOG_STYLE_INPUT,"Farbe 1 angeben:","Bitte gebe die 1. Farbe an, die das Fahrzeug besitzen soll:","Weiter","Abbrechen");
  225.         }return ShowPlayerDialog(playerid,fDialog_Vehid,DIALOG_STYLE_INPUT,"Fraktionsfahrzeug erstellen:","Fehler!\nUnbekannte Vehicle-ID (Nur 400 - 611)\n\nBitte gebe die Vehicle-ID des Fahrzeuges an, das du erstellen möchtest:","Weiter","Abbrechen");
  226.     }
  227.     if(dialogid==fDialog_Col1){
  228.         if(!response) return SendClientMessage(playerid,fColGrey,"Du hast den Vorgang abgebrochen.");
  229.         if((strval(inputtext) >= 0 && strval(inputtext) <= 126) || (strval(inputtext) >= 130 && strval(inputtext) <= 132) || (strval(inputtext) == 142 || strval(inputtext) == 144) || (strval(inputtext) >= 146 && strval(inputtext) <= 161) || (strval(inputtext) >= 173 && strval(inputtext) <= 175) || (strval(inputtext) == 236 ||strval(inputtext) == 237 ||strval(inputtext) == 239 ||strval(inputtext) == 243 ||strval(inputtext) == 252)){
  230.             SetPVarInt(playerid,"fCol1",strval(inputtext));
  231.             return ShowPlayerDialog(playerid,fDialog_Col2,DIALOG_STYLE_INPUT,"Farbe 2 angeben:","Bitte gebe die 2. Farbe an, die das Fahrzeug besitzen soll:","Weiter","Abbrechen");
  232.         }return ShowPlayerDialog(playerid,fDialog_Col1,DIALOG_STYLE_INPUT,"Farbe 1 angeben:","Fehler!\nUnbekannte Farb-ID\n\nBitte gebe die 1. Farbe an, die das Fahrzeug besitzen soll:","Weiter","Abbrechen");
  233.     }
  234.     if(dialogid==fDialog_Col2){
  235.         if(!response) return SendClientMessage(playerid,fColGrey,"Du hast den Vorgang abgebrochen.");
  236.         if((strval(inputtext) >= 0 && strval(inputtext) <= 126) || (strval(inputtext) >= 130 && strval(inputtext) <= 132) || (strval(inputtext) == 142 || strval(inputtext) == 144) || (strval(inputtext) >= 146 && strval(inputtext) <= 161) || (strval(inputtext) >= 173 && strval(inputtext) <= 175) || (strval(inputtext) == 236 ||strval(inputtext) == 237 ||strval(inputtext) == 239 ||strval(inputtext) == 243 ||strval(inputtext) == 252)){
  237.             SetPVarInt(playerid,"fCol2",strval(inputtext));
  238.             return ShowPlayerDialog(playerid,fDialog_Fraction1,DIALOG_STYLE_INPUT,"Hauptfraktion angeben:","Bitte gebe nun die Fraktion an die das Fahrzeug Besitzen soll:","Erstellen","Weiter");
  239.         }return ShowPlayerDialog(playerid,fDialog_Col2,DIALOG_STYLE_INPUT,"Farbe 2 angeben:","Fehler!\nUnbekannte Farb-ID\n\nBitte gebe die 2. Farbe an, die das Fahrzeug besitzen soll:","Weiter","Abbrechen");
  240.     }
  241.     if(dialogid==fDialog_Fraction1){
  242.         new Fractiontext[1024];
  243.         if(response){
  244.             if(strval(inputtext) >= 1 && strval(inputtext) <= MAX_FRACTIONS){
  245.                 SetPVarInt(playerid,"fFraction1",strval(inputtext));
  246.                 SetPVarInt(playerid,"fFraction2",-255);
  247.                 SetPVarInt(playerid,"fFraction3",-255);
  248.                 SetPVarInt(playerid,"fFraction4",-255);
  249.                 SetPVarInt(playerid,"fFraction5",-255);
  250.                 format(Fractiontext,sizeof(Fractiontext),"Fraktionsfahrzeug erstellen:\n\nFahrzeug: %s (ID:%d)\n1. Farbe: %d\n2. Farbe: %d\nHauptfraktion: %d\n2. Fraktion: N/A\n3. Fraktion: N/A\n4. Fraktion: N/A\n5. Fraktion: N/A\n\nUm das Fraktionsfahrzeug zu erstellen drücke den Button: 'Erstellen'.",
  251.                 fCarName[GetPVarInt(playerid,"fVehid")-400],
  252.                 GetPVarInt(playerid,"fVehid"),
  253.                 GetPVarInt(playerid,"fCol1"),
  254.                 GetPVarInt(playerid,"fCol2"),
  255.                 strval(inputtext));
  256.                 return ShowPlayerDialog(playerid,fDialog_Create,DIALOG_STYLE_MSGBOX,"Bestätige:",Fractiontext,"Erstellen","Abbrechen");
  257.             }
  258.             format(Fractiontext,sizeof(Fractiontext),"Fehler!\nFraktionen nur von 1 - %d\n\nBitte gebe nun die Fraktion an die das Fahrzeug Besitzen soll:",MAX_FRACTIONS);
  259.             return ShowPlayerDialog(playerid,fDialog_Fraction1,DIALOG_STYLE_INPUT,"Hauptfraktion angeben:",Fractiontext,"Erstellen","Weiter");
  260.         }
  261.         if(!response){
  262.             if(strval(inputtext) >= 1 && strval(inputtext) <= MAX_FRACTIONS){
  263.                 SetPVarInt(playerid,"fFraction1",strval(inputtext));
  264.                 return ShowPlayerDialog(playerid,fDialog_Fraction2,DIALOG_STYLE_INPUT,"Weitere Fraktion angeben:","Bitte gebe nun eine Fraktion an die das Fahrzeug benutzen darf:","Erstellen","Weiter");
  265.             }
  266.             format(Fractiontext,sizeof(Fractiontext),"Fehler!\nFraktionen nur von 1 - %d\n\nBitte gebe nun die Fraktion an die das Fahrzeug Besitzen soll:",MAX_FRACTIONS);
  267.             return ShowPlayerDialog(playerid,fDialog_Fraction1,DIALOG_STYLE_INPUT,"Hauptfraktion angeben:",Fractiontext,"Erstellen","Weiter");
  268.         }
  269.     }
  270.     if(dialogid==fDialog_Fraction2){
  271.         new Fractiontext[1024];
  272.         if(response){
  273.             if(strval(inputtext) >= 1 && strval(inputtext) <= MAX_FRACTIONS){
  274.                 SetPVarInt(playerid,"fFraction2",strval(inputtext));
  275.                 SetPVarInt(playerid,"fFraction3",-255);
  276.                 SetPVarInt(playerid,"fFraction4",-255);
  277.                 SetPVarInt(playerid,"fFraction5",-255);
  278.                 format(Fractiontext,sizeof(Fractiontext),"Fraktionsfahrzeug erstellen:\n\nFahrzeug: %s (ID:%d)\n1. Farbe: %d\n2. Farbe: %d\nHauptfraktion: %d\n2. Fraktion: %d\n3. Fraktion: N/A\n4. Fraktion: N/A\n5. Fraktion: N/A\n\nUm das Fraktionsfahrzeug zu erstellen drücke den Button: 'Erstellen'.",
  279.                 fCarName[GetPVarInt(playerid,"fVehid")-400],
  280.                 GetPVarInt(playerid,"fVehid"),
  281.                 GetPVarInt(playerid,"fCol1"),
  282.                 GetPVarInt(playerid,"fCol2"),
  283.                 GetPVarInt(playerid,"fFraction1"),
  284.                 strval(inputtext));
  285.                 return ShowPlayerDialog(playerid,fDialog_Create,DIALOG_STYLE_MSGBOX,"Bestätige:",Fractiontext,"Erstellen","Abbrechen");
  286.             }
  287.             format(Fractiontext,sizeof(Fractiontext),"Fehler!\nFraktionen nur von 1 - %d\n\nBitte gebe nun die Fraktion an die das Fahrzeug benutzen darf:",MAX_FRACTIONS);
  288.             return ShowPlayerDialog(playerid,fDialog_Fraction2,DIALOG_STYLE_INPUT,"Weitere Fraktion angeben:",Fractiontext,"Erstellen","Weiter");
  289.         }
  290.         if(!response){
  291.             if(strval(inputtext) >= 1 && strval(inputtext) <= MAX_FRACTIONS){
  292.                 SetPVarInt(playerid,"fFraction2",strval(inputtext));
  293.                 return ShowPlayerDialog(playerid,fDialog_Fraction3,DIALOG_STYLE_INPUT,"Weitere Fraktion angeben:","Bitte gebe nun eine Fraktion an die das Fahrzeug benutzen darf:","Erstellen","Weiter");
  294.             }
  295.             format(Fractiontext,sizeof(Fractiontext),"Fehler!\nFraktionen nur von 1 - %d\n\nBitte gebe nun die Fraktion an die das Fahrzeug benutzen darf:",MAX_FRACTIONS);
  296.             return ShowPlayerDialog(playerid,fDialog_Fraction2,DIALOG_STYLE_INPUT,"Weitere Fraktion angeben:",Fractiontext,"Erstellen","Weiter");
  297.         }
  298.     }
  299.     if(dialogid==fDialog_Fraction3){
  300.         new Fractiontext[1024];
  301.         if(response){
  302.             if(strval(inputtext) >= 1 && strval(inputtext) <= MAX_FRACTIONS){
  303.                 SetPVarInt(playerid,"fFraction3",strval(inputtext));
  304.                 SetPVarInt(playerid,"fFraction4",-255);
  305.                 SetPVarInt(playerid,"fFraction5",-255);
  306.                 format(Fractiontext,sizeof(Fractiontext),"Fraktionsfahrzeug erstellen:\n\nFahrzeug: %s (ID:%d)\n1. Farbe: %d\n2. Farbe: %d\nHauptfraktion: %d\n2. Fraktion: %d\n3. Fraktion: %d\n4. Fraktion: N/A\n5. Fraktion: N/A\n\nUm das Fraktionsfahrzeug zu erstellen drücke den Button: 'Erstellen'.",
  307.                 fCarName[GetPVarInt(playerid,"fVehid")-400],
  308.                 GetPVarInt(playerid,"fVehid"),
  309.                 GetPVarInt(playerid,"fCol1"),
  310.                 GetPVarInt(playerid,"fCol2"),
  311.                 GetPVarInt(playerid,"fFraction1"),
  312.                 GetPVarInt(playerid,"fFraction2"),
  313.                 strval(inputtext));
  314.                 return ShowPlayerDialog(playerid,fDialog_Create,DIALOG_STYLE_MSGBOX,"Bestätige:",Fractiontext,"Erstellen","Abbrechen");
  315.             }
  316.             format(Fractiontext,sizeof(Fractiontext),"Fehler!\nFraktionen nur von 1 - %d\n\nBitte gebe nun die Fraktion an die das Fahrzeug benutzen darf:",MAX_FRACTIONS);
  317.             return ShowPlayerDialog(playerid,fDialog_Fraction3,DIALOG_STYLE_INPUT,"Weitere Fraktion angeben:",Fractiontext,"Erstellen","Weiter");
  318.         }
  319.         if(!response){
  320.             if(strval(inputtext) >= 1 && strval(inputtext) <= MAX_FRACTIONS){
  321.                 SetPVarInt(playerid,"fFraction3",strval(inputtext));
  322.                 return ShowPlayerDialog(playerid,fDialog_Fraction4,DIALOG_STYLE_INPUT,"Weitere Fraktion angeben:","Bitte gebe nun eine Fraktion an die das Fahrzeug benutzen darf:","Erstellen","Weiter");
  323.             }
  324.             format(Fractiontext,sizeof(Fractiontext),"Fehler!\nFraktionen nur von 1 - %d\n\nBitte gebe nun die Fraktion an die das Fahrzeug benutzen darf:",MAX_FRACTIONS);
  325.             return ShowPlayerDialog(playerid,fDialog_Fraction3,DIALOG_STYLE_INPUT,"Weitere Fraktion angeben:",Fractiontext,"Erstellen","Weiter");
  326.         }
  327.     }
  328.     if(dialogid==fDialog_Fraction4){
  329.         new Fractiontext[1024];
  330.         if(response){
  331.             if(strval(inputtext) >= 1 && strval(inputtext) <= MAX_FRACTIONS){
  332.                 SetPVarInt(playerid,"fFraction4",strval(inputtext));
  333.                 SetPVarInt(playerid,"fFraction5",-255);
  334.                 format(Fractiontext,sizeof(Fractiontext),"Fraktionsfahrzeug erstellen:\n\nFahrzeug: %s (ID:%d)\n1. Farbe: %d\n2. Farbe: %d\nHauptfraktion: %d\n2. Fraktion: %d\n3. Fraktion: %d\n4. Fraktion: %d\n5. Fraktion: N/A\n\nUm das Fraktionsfahrzeug zu erstellen drücke den Button: 'Erstellen'.",
  335.                 fCarName[GetPVarInt(playerid,"fVehid")-400],
  336.                 GetPVarInt(playerid,"fVehid"),
  337.                 GetPVarInt(playerid,"fCol1"),
  338.                 GetPVarInt(playerid,"fCol2"),
  339.                 GetPVarInt(playerid,"fFraction1"),
  340.                 GetPVarInt(playerid,"fFraction2"),
  341.                 GetPVarInt(playerid,"fFraction3"),
  342.                 strval(inputtext));
  343.                 return ShowPlayerDialog(playerid,fDialog_Create,DIALOG_STYLE_MSGBOX,"Bestätige:",Fractiontext,"Erstellen","Abbrechen");
  344.             }
  345.             format(Fractiontext,sizeof(Fractiontext),"Fehler!\nFraktionen nur von 1 - %d\n\nBitte gebe nun die Fraktion an die das Fahrzeug benutzen darf:",MAX_FRACTIONS);
  346.             return ShowPlayerDialog(playerid,fDialog_Fraction4,DIALOG_STYLE_INPUT,"Weitere Fraktion angeben:",Fractiontext,"Erstellen","Weiter");
  347.         }
  348.         if(!response){
  349.             if(strval(inputtext) >= 1 && strval(inputtext) <= MAX_FRACTIONS){
  350.                 SetPVarInt(playerid,"fFraction4",strval(inputtext));
  351.                 return ShowPlayerDialog(playerid,fDialog_Fraction5,DIALOG_STYLE_INPUT,"Weitere Fraktion angeben:","Bitte gebe nun eine Fraktion an die das Fahrzeug benutzen darf:","Erstellen","Abbrechen");
  352.             }
  353.             format(Fractiontext,sizeof(Fractiontext),"Fehler!\nFraktionen nur von 1 - %d\n\nBitte gebe nun die Fraktion an die das Fahrzeug benutzen darf:",MAX_FRACTIONS);
  354.             return ShowPlayerDialog(playerid,fDialog_Fraction4,DIALOG_STYLE_INPUT,"Weitere Fraktion angeben:",Fractiontext,"Erstellen","Weiter");
  355.         }
  356.     }
  357.     if(dialogid==fDialog_Fraction5){
  358.         if(!response){
  359.             return SendClientMessage(playerid,fColGrey,"Du hast den Vorgang abgebrochen.");
  360.         }
  361.         if(response){
  362.             new Fractiontext[1024];
  363.             if(strval(inputtext) >= 1 && strval(inputtext) <= MAX_FRACTIONS){
  364.                 SetPVarInt(playerid,"fFraction5",strval(inputtext));
  365.                 format(Fractiontext,sizeof(Fractiontext),"Fraktionsfahrzeug erstellen:\n\nFahrzeug: %s (ID:%d)\n1. Farbe: %d\n2. Farbe: %d\nHauptfraktion: %d\n2. Fraktion: %d\n3. Fraktion: %d\n4. Fraktion: %d\n5. Fraktion: %d\n\nUm das Fraktionsfahrzeug zu erstellen drücke den Button: 'Erstellen'.",
  366.                 fCarName[GetPVarInt(playerid,"fVehid")-400],
  367.                 GetPVarInt(playerid,"fVehid"),
  368.                 GetPVarInt(playerid,"fCol1"),
  369.                 GetPVarInt(playerid,"fCol2"),
  370.                 GetPVarInt(playerid,"fFraction1"),
  371.                 GetPVarInt(playerid,"fFraction2"),
  372.                 GetPVarInt(playerid,"fFraction3"),
  373.                 GetPVarInt(playerid,"fFraction4"),
  374.                 strval(inputtext));
  375.                 return ShowPlayerDialog(playerid,fDialog_Create,DIALOG_STYLE_MSGBOX,"Bestätige:",Fractiontext,"Erstellen","Abbrechen");
  376.             }
  377.             format(Fractiontext,sizeof(Fractiontext),"Fehler!\nFraktionen nur von 1 - %d\n\nBitte gebe nun die Fraktion an die das Fahrzeug benutzen darf:",MAX_FRACTIONS);
  378.             return ShowPlayerDialog(playerid,fDialog_Fraction5,DIALOG_STYLE_INPUT,"Weitere Fraktion angeben:",Fractiontext,"Erstellen","Weiter");
  379.         }
  380.     }
  381.     if(dialogid==fDialog_Create){
  382.         if(!response){
  383.             return SendClientMessage(playerid,fColGrey,"Du hast den Vorgang abgebrochen.");
  384.         }
  385.         new fc;while(fc<MAX_FRACTION_CARS){
  386.             if(FractionCars[fc][fVehid] <= 400 || FractionCars[fc][fVehid] >= 611){
  387.                 FractionCars[fc][fVehid] = GetPVarInt(playerid,"fVehid");
  388.                 new Float:fX,Float:fY,Float:fZ,Float:fA;
  389.                 GetPlayerPos(playerid,fX,fY,fZ),GetPlayerFacingAngle(playerid,fA);
  390.                 FractionCars[fc][fPos][0] = fX;
  391.                 FractionCars[fc][fPos][1] = fY;
  392.                 FractionCars[fc][fPos][2] = fZ;
  393.                 FractionCars[fc][fPos][3] = fA;
  394.                 FractionCars[fc][fCol][0] = GetPVarInt(playerid,"fCol1");
  395.                 FractionCars[fc][fCol][1] = GetPVarInt(playerid,"fCol2");
  396.                 FractionCars[fc][fFraction][0] = GetPVarInt(playerid,"fFraction1");
  397.                 FractionCars[fc][fFraction][1] = GetPVarInt(playerid,"fFraction2");
  398.                 FractionCars[fc][fFraction][2] = GetPVarInt(playerid,"fFraction3");
  399.                 FractionCars[fc][fFraction][3] = GetPVarInt(playerid,"fFraction4");
  400.                 FractionCars[fc][fFraction][4] = GetPVarInt(playerid,"fFraction5");
  401.                 FractionCars[fc][fCarid] = CreateVehicle(FractionCars[fc][fVehid],FractionCars[fc][fPos][0],FractionCars[fc][fPos][1],FractionCars[fc][fPos][2],FractionCars[fc][fPos][3],FractionCars[fc][fCol][0],FractionCars[fc][fCol][1],-255);
  402.                 FractionCars[fc][fLock] = true;
  403.                 SendClientMessage(playerid,fColYellow,">>> Du hast das Fraktionsfahrzeug erfolgreich erstellt.");
  404.                 SendClientMessage(playerid,fColYellow,">>> Vergesse es nicht mit '/fpark' zu umzuparken.");
  405.                 PutPlayerInVehicle(playerid,FractionCars[fc][fCarid],0);
  406.                 return true;
  407.             }fc++;
  408.         }
  409.     }return false;
  410. }
  411.  
  412. public FractionLockDoors(){
  413.     for(new i;i<GetMaxPlayers();i++){
  414.         if(IsPlayerConnected(i) && !IsPlayerNPC(i)){
  415.             new fc;while(fc<MAX_FRACTION_CARS){
  416.                 if(FractionCars[fc][fVehid] >= 400 && FractionCars[fc][fVehid] <= 611){
  417.                     if(FractionCars[fc][fLock]){
  418.                         if(PlayerFraction(i)==FractionCars[fc][fFraction][0]||PlayerFraction(i)==FractionCars[fc][fFraction][1]||PlayerFraction(i)==FractionCars[fc][fFraction][2]||PlayerFraction(i)==FractionCars[fc][fFraction][3]||PlayerFraction(i)==FractionCars[fc][fFraction][4]||PlayerAdministrator(i)>=Fraction_Need_Adminlevel)
  419.                             SetVehicleParamsForPlayer(FractionCars[fc][fCarid],i,0,0);
  420.                         else
  421.                             SetVehicleParamsForPlayer(FractionCars[fc][fCarid],i,0,1);
  422.                     }
  423.                 }fc++;
  424.             }
  425.         }
  426.     }return 1;
  427. }
  428.  
  429. public LoadFractionCars(){
  430.     if(!fexist(Fraction_Car_File)){
  431.         new File:tfFile=fopen(Fraction_Car_File,io_write);
  432.         fclose(tfFile);
  433.     }
  434.     new File:fFile=fopen(Fraction_Car_File,io_read),Content[512],fc;
  435.     while(fread(fFile,Content)){
  436.         StripNewLine(Content);
  437.         sscanf(Content,"dffffddddddd",FractionCars[fc][fVehid],FractionCars[fc][fPos][0],FractionCars[fc][fPos][1],FractionCars[fc][fPos][2],FractionCars[fc][fPos][3],FractionCars[fc][fCol][0],FractionCars[fc][fCol][1],FractionCars[fc][fFraction][0],FractionCars[fc][fFraction][1],FractionCars[fc][fFraction][2],FractionCars[fc][fFraction][3],FractionCars[fc][fFraction][4]);
  438.         if(FractionCars[fc][fVehid] >= 400 && FractionCars[fc][fVehid] <= 611)
  439.         {
  440.             FractionCars[fc][fCarid] = CreateVehicle(FractionCars[fc][fVehid],FractionCars[fc][fPos][0],FractionCars[fc][fPos][1],FractionCars[fc][fPos][2],FractionCars[fc][fPos][3],FractionCars[fc][fCol][0],FractionCars[fc][fCol][1],-255);
  441.             FractionCars[fc][fLock] = true;
  442.             fc++;
  443.         }
  444.     }
  445.     fclose(fFile);
  446.     return printf("  '%d' Fraktionsfahrzeug(e) wurden geladen & erstellt.",fc);
  447. }
  448. public SaveFractionCars(){
  449.     if(fexist(Fraction_Car_File)) fremove(Fraction_Car_File);
  450.     new File:fFile=fopen(Fraction_Car_File,io_append),Content[512];
  451.     new fc;while(fc<MAX_FRACTION_CARS){
  452.         if(FractionCars[fc][fVehid] >= 400 && FractionCars[fc][fVehid] <= 611){
  453.             format(Content,sizeof(Content),"%d %.3f %.3f %.3f %.3f %03d %03d %02d %02d %02d %02d %02d\r\n",FractionCars[fc][fVehid],FractionCars[fc][fPos][0],FractionCars[fc][fPos][1],FractionCars[fc][fPos][2],FractionCars[fc][fPos][3],FractionCars[fc][fCol][0],FractionCars[fc][fCol][1],FractionCars[fc][fFraction][0],FractionCars[fc][fFraction][1],FractionCars[fc][fFraction][2],FractionCars[fc][fFraction][3],FractionCars[fc][fFraction][4]);
  454.             fwrite(fFile,Content);
  455.         }fc++;
  456.     }return fclose(fFile);
  457. }
  458. public DestroyAndCreateFractionCar(fc){
  459.     if(FractionCars[fc][fVehid] >= 400 && FractionCars[fc][fVehid] <= 611){
  460.         DestroyVehicle(FractionCars[fc][fCarid]);
  461.         FractionCars[fc][fCarid] = CreateVehicle(FractionCars[fc][fVehid],FractionCars[fc][fPos][0],FractionCars[fc][fPos][1],FractionCars[fc][fPos][2],FractionCars[fc][fPos][3],FractionCars[fc][fCol][0],FractionCars[fc][fCol][1],-255);
  462.         return true;
  463.     }return false;
  464. }
  465. public RemoveFromCar(playerid){
  466.     return RemovePlayerFromVehicle(playerid);
  467. }
  468. public fLockCar(Carid){
  469.     for(new i;i<GetMaxPlayers();i++){
  470.         SetVehicleParamsForPlayer(Carid,i,0,1);
  471.     }return 1;
  472. }
  473. public fUnlockCar(Carid){
  474.     for(new i;i<GetMaxPlayers();i++){
  475.         SetVehicleParamsForPlayer(Carid,i,0,0);
  476.     }return 1;
  477. }
  478. stock PlayerAdministrator(playerid){
  479.     if(IsPlayerAdmin(playerid))
  480.         return Fraction_Need_Adminlevel;
  481.     return CallRemoteFunction("GetPlayerAdminLevel","i",playerid);
  482. }
  483. stock PlayerFraction(playerid){
  484.     new Leader=PlayerLeader(playerid);
  485.     if(Leader)
  486.         return Leader;
  487.     new Member=PlayerMember(playerid);
  488.     if(Member)
  489.         return Member;
  490.     return false;
  491. }
  492. stock PlayerLeader(playerid){
  493.     return CallRemoteFunction("GetPlayerLeader","i",playerid);
  494. }
  495. stock PlayerMember(playerid){
  496.     return CallRemoteFunction("GetPlayerMember","i",playerid);
  497. }
  498. stock sscanf(string[],format[],{Float,_}:...){
  499.     new formatPos=0,stringPos=0,paramPos=2,paramCount=numargs();
  500.     while(paramPos < paramCount && string[stringPos]){
  501.         switch (format[formatPos++]){
  502.             case '\0':{return 0;}case 'i','d':{
  503.                 new neg=1,num=0,ch=string[stringPos];
  504.                 if(ch=='-'){neg=-1;ch=string[++stringPos];}
  505.                 do{ stringPos++;
  506.                     if(ch>='0'&&ch<='9'){num=(num*10)+(ch-'0');}else{return 1;}
  507.                 }while((ch=string[stringPos])&&ch!=' ');setarg(paramPos,0,num*neg);}
  508.             case 'h','x':{
  509.                 new ch,num=0;while((ch=string[stringPos++])){
  510.                     switch (ch){
  511.                         case 'x','X':{num=0;continue;}case '0'..'9':{num=(num<<4)|(ch-'0');}
  512.                         case 'a'..'f':{num=(num<<4)|(ch-('a'-10));}case 'A'..'F':{num=(num<<4)|(ch-('A'-10));}
  513.                         case ' ':{break;}default:{return 1;}}
  514.                 }setarg(paramPos,0,num);}
  515.             case 'c':{setarg(paramPos,0,string[stringPos++]);}
  516.             case 'f':{
  517.                 new tmp[25];
  518.                 strmid(tmp,string,stringPos,stringPos+sizeof(tmp)-2);
  519.                 setarg(paramPos,0,_:floatstr(tmp));}
  520.             case 's','z':{
  521.                 new i=0,ch;
  522.                 if(format[formatPos]){
  523.                     while ((ch=string[stringPos++])&&ch!=' '){
  524.                         setarg(paramPos,i++,ch);
  525.                     }if(!i)return 1;
  526.                 }else{while((ch=string[stringPos++])){setarg(paramPos,i++,ch);}
  527.                 }stringPos--;setarg(paramPos,i,'\0');
  528.             }default:{continue;}}
  529.         while(string[stringPos]&&string[stringPos]!=' '){stringPos++;}
  530.         while(string[stringPos]==' '){stringPos++;}
  531.         paramPos++;}
  532.     while(format[formatPos]=='z')formatPos++;
  533.     return format[formatPos];
  534. }
  535. stock StripNewLine(string[]){
  536.     new len=strlen(string);
  537.     if(string[0]==0)return;if((string[len-1]=='\n')||(string[len-1]=='\r')){
  538.         string[len-1]=0; if(string[0]==0) return; if((string[len-2]=='\n')||(string[len-2]=='\r'))string[len-2]=0;
  539.     }
  540. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement