Advertisement
Guest User

FraktionsAutohaus-System

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