Guest User

KABOOM - GAMEMODE

a guest
Oct 22nd, 2012
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.08 KB | None | 0 0
  1. //###############################//
  2. //** German RealLife Adventure **//
  3. //**           v1.0.0          **//
  4. //###############################//
  5. /*'includes'*/
  6. #include <a_samp>
  7. #include <ocmd>
  8. #include <dini>
  9. #include <sscanf>
  10.  
  11. /*'defines'*/
  12. #define startposx 1958.3783 //Startposition X Kooridinate (erster Spawn nach dem Reg. danach wird die Position gespeichert)
  13. #define startposy 1343.1572 //Y Koordinate
  14. #define startposz 15.3746 //Z Koordinate
  15. #define startposa 269.1425 // Angle Koordinate
  16.  
  17. #define DIALOG_LOGIN 1
  18. #define DIALOG_REGISTER 2
  19.  
  20. #define COLOR_RED 0xFF0A00FF
  21. #define COLOR_GREEN 0x0FFF00FF
  22. #define COLOR_BLACK 0x000000FF
  23. #define COLOR_WHITE 0xFFFFFFFF
  24. #define COLOR_BLUE 0x004BFFFF
  25.  
  26. /*'enums'*/
  27. enum spieler_daten
  28. {
  29. Float:lastx, Float:lasty, Float:lastz, Float:lasta, //a = Angle
  30. eingeloggt
  31. }
  32. new Spieler[MAX_PLAYERS][spieler_daten];
  33.  
  34. /*'forwards'*/
  35. forward SpielerSpeicher(playerid);
  36.  
  37. /*'##########################################################################'*/
  38. /*'##########################################################################'*/
  39. main()
  40. {
  41.     print("\n---------------------------------");
  42.     print(" **German RealLife Adventure v1.0.0");
  43.     print("---------------------------------\n");
  44. }
  45.  
  46. public OnGameModeInit()
  47. {
  48.     SetGameModeText("GRLA v1.0.0");
  49.     return 1;
  50. }
  51.  
  52. public OnGameModeExit()
  53. {
  54.     return 1;
  55. }
  56.  
  57. public OnPlayerRequestClass(playerid, classid)
  58. {
  59.     new pname[MAX_PLAYERS],accFormat[128];
  60.     GetPlayerName(playerid,pname,sizeof pname);
  61.     format(accFormat,sizeof accFormat,"%s.txt",pname);
  62.     if(dini_Isset(accFormat,"lastx"))
  63.     {
  64.         SetSpawnInfo(playerid,0,0,Spieler[playerid][lastx],Spieler[playerid][lasty],Spieler[playerid][lastz],Spieler[playerid][lasta],0,0,0,0,0,0);
  65.         SpawnPlayer(playerid);
  66.     }
  67.     else
  68.     {
  69.         SetSpawnInfo(playerid,0,0,Float:lastx,Float:lasty,Float:lastz,Float:lasta,0,0,0,0,0,0);
  70.         SpawnPlayer(playerid);
  71.     }
  72.     return 1;
  73. }
  74.  
  75. public OnPlayerConnect(playerid)
  76. {
  77.     new pname[MAX_PLAYERS],accFormat[128];
  78.     GetPlayerName(playerid,pname,sizeof pname);
  79.     format(accFormat,sizeof accFormat,"Accounts/%s.txt",pname);
  80.     if(fexist(accFormat))
  81.     {
  82.         ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Bitte logge dich ein","Login","Abbrechen");
  83.     }
  84.     else
  85.     {
  86.         ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_PASSWORD,"Registration","Bitte Registriere dich","Register","Abbrechen");
  87.     }
  88.     return 1;
  89. }
  90.  
  91. public OnPlayerDisconnect(playerid, reason)
  92. {
  93.     SpielerSpeichern(playerid);
  94.     return 1;
  95. }
  96.  
  97. public OnPlayerSpawn(playerid)
  98. {
  99.     SetCameraBehindPlayer(playerid);
  100.     return 1;
  101. }
  102.  
  103. public OnPlayerDeath(playerid, killerid, reason)
  104. {
  105.     return 1;
  106. }
  107.  
  108. public OnVehicleSpawn(vehicleid)
  109. {
  110.     return 1;
  111. }
  112.  
  113. public OnVehicleDeath(vehicleid, killerid)
  114. {
  115.     return 1;
  116. }
  117.  
  118. public OnPlayerText(playerid, text[])
  119. {
  120.     return 1;
  121. }
  122.  
  123. public OnPlayerCommandText(playerid, cmdtext[])
  124. {
  125.     return 0;
  126. }
  127.  
  128. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  129. {
  130.     return 1;
  131. }
  132.  
  133. public OnPlayerExitVehicle(playerid, vehicleid)
  134. {
  135.     return 1;
  136. }
  137.  
  138. public OnPlayerStateChange(playerid, newstate, oldstate)
  139. {
  140.     return 1;
  141. }
  142.  
  143. public OnPlayerEnterCheckpoint(playerid)
  144. {
  145.     return 1;
  146. }
  147.  
  148. public OnPlayerLeaveCheckpoint(playerid)
  149. {
  150.     return 1;
  151. }
  152.  
  153. public OnPlayerEnterRaceCheckpoint(playerid)
  154. {
  155.     return 1;
  156. }
  157.  
  158. public OnPlayerLeaveRaceCheckpoint(playerid)
  159. {
  160.     return 1;
  161. }
  162.  
  163. public OnRconCommand(cmd[])
  164. {
  165.     return 1;
  166. }
  167.  
  168. public OnPlayerRequestSpawn(playerid)
  169. {
  170.     return 1;
  171. }
  172.  
  173. public OnObjectMoved(objectid)
  174. {
  175.     return 1;
  176. }
  177.  
  178. public OnPlayerObjectMoved(playerid, objectid)
  179. {
  180.     return 1;
  181. }
  182.  
  183. public OnPlayerPickUpPickup(playerid, pickupid)
  184. {
  185.     return 1;
  186. }
  187.  
  188. public OnVehicleMod(playerid, vehicleid, componentid)
  189. {
  190.     return 1;
  191. }
  192.  
  193. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  194. {
  195.     return 1;
  196. }
  197.  
  198. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  199. {
  200.     return 1;
  201. }
  202.  
  203. public OnPlayerSelectedMenuRow(playerid, row)
  204. {
  205.     return 1;
  206. }
  207.  
  208. public OnPlayerExitedMenu(playerid)
  209. {
  210.     return 1;
  211. }
  212.  
  213. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  214. {
  215.     return 1;
  216. }
  217.  
  218. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  219. {
  220.     return 1;
  221. }
  222.  
  223. public OnRconLoginAttempt(ip[], password[], success)
  224. {
  225.     return 1;
  226. }
  227.  
  228. public OnPlayerUpdate(playerid)
  229. {
  230.     return 1;
  231. }
  232.  
  233. public OnPlayerStreamIn(playerid, forplayerid)
  234. {
  235.     return 1;
  236. }
  237.  
  238. public OnPlayerStreamOut(playerid, forplayerid)
  239. {
  240.     return 1;
  241. }
  242.  
  243. public OnVehicleStreamIn(vehicleid, forplayerid)
  244. {
  245.     return 1;
  246. }
  247.  
  248. public OnVehicleStreamOut(vehicleid, forplayerid)
  249. {
  250.     return 1;
  251. }
  252.  
  253. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  254. {
  255.     new pname[MAX_PLAYERS],accFormat[128];
  256.     GetPlayerName(playerid,pname,sizeof pname);
  257.     format(accFormat,sizeof accFormat,"Accounts/%s.txt",pname);
  258.     if(response)
  259.     {
  260.         switch(dialogid)
  261.         {
  262.             case DIALOG_LOGIN:
  263.             {
  264.                 if(!strlen(inputtext))
  265.                 {
  266.                     ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Bitte logge dich ein","Abbrechen","Weiter");
  267.                     return SendClientMessage(playerid,COLOR_WHITE,"-SERVER- Dein angegebenes Passwort ist leider falsch.");
  268.                 }
  269.                 if(strcmp(inputtext,dini_Get(accFormat,"Passwort")) == 0)
  270.                 {
  271.                     Spieler[playerid][lastx] = dini_Float(accFormat,"lastx");
  272.                     Spieler[playerid][lasty] = dini_Float(accFormat,"lasty");
  273.                     Spieler[playerid][lastz] = dini_Float(accFormat,"lastz");
  274.                     Spieler[playerid][lasta] = dini_Float(accFormat,"lasta");
  275.                     Spieler[playerid][eingeloggt] = 1;
  276.                     SendClientMessage(playerid,COLOR_WHITE,"-Server- Du wurdest erfolgreich eingeloggt.");
  277.                     SetPlayerPos(playerid,Spieler[playerid][lastx],Spieler[playerid][lasty],Spieler[playerid][lastz]);
  278.                     SetPlayerFacingAngle(playerid,Spieler[playerid][lasta]);
  279.                 }
  280.                 else
  281.                 {
  282.                     ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Bitte logge dich ein","Login","Abbrechen");
  283.                     SendClientMessage(playerid,COLOR_WHITE,"-SERVER- Dein angegebenes Passwort war leider falsch.");
  284.                 }
  285.             }
  286.             case DIALOG_REGISTER:
  287.             {
  288.                 if(!strlen(inputtext))
  289.                 {
  290.                         ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_PASSWORD,"REGISTRATION","Bitte Registriere dich","Register","Abbrechen");
  291.                         return SendClientMessage(playerid,COLOR_WHITE,"Bitte fülle das Feld aus.");
  292.                 }
  293.                 dini_Create(accFormat);
  294.                 dini_Set(accFormat,"Passwort",inputtext);
  295.                 dini_FloatSet(accFormat,"lastx",0.0);
  296.                 dini_FloatSet(accFormat,"lasty",0.0);
  297.                 dini_FloatSet(accFormat,"lastz",0.0);
  298.                 dini_FloatSet(accFormat,"lasta",0.0);
  299.                 Spieler[playerid][eingeloggt] = 1;
  300.                 SendClientMessage(playerid,COLOR_WHITE,"-Server- Dein Account wurde in unserer Datenbank erfolgreich registriert, und du wurdest erfolgreich eingeloggt.");
  301.                 SetPlayerPos(playerid,startposx,startposy,startposz);
  302.                 SetPlayerFacingAngle(playerid,startposa);
  303.             }
  304.         }
  305.     }
  306.     else
  307.     {
  308.         switch(dialogid)
  309.         {
  310.             case DIALOG_LOGIN:ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Bitte logge dich ein","Login","Abbrechen");
  311.             case DIALOG_REGISTER:ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_PASSWORD,"Registration","Bitte Registriere dich","Register","Abbrechen");
  312.         }
  313.     }
  314.     return 1;
  315. }
  316.  
  317. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  318. {
  319.     return 1;
  320. }
  321.  
  322. stock SpielerSpeichern(playerid)
  323. {
  324.     new pname[MAX_PLAYERS],accFormat[128];
  325.     GetPlayerName(playerid,pname,sizeof pname);
  326.     format(accFormat,sizeof accFormat,"Accounts/%s.txt",pname);
  327.     if(fexist(accFormat) && Spieler[playerid][eingeloggt])
  328.     {
  329.         GetPlayerPos(playerid,Spieler[playerid][lastx],Spieler[playerid][lasty],Spieler[playerid][lastz]);
  330.         GetPlayerFacingAngle(playerid,Spieler[playerid][lasta]);
  331.         dini_FloatSet(accFormat,"lastx",Spieler[playerid][lastx]);
  332.         dini_FloatSet(accFormat,"lasty",Spieler[playerid][lasty]);
  333.         dini_FloatSet(accFormat,"lastz",Spieler[playerid][lastz]);
  334.         dini_FloatSet(accFormat,"lasta",Spieler[playerid][lasta]);
  335.     }
  336.     return 1;
  337. }
  338.  
  339. ocmd:spawnme(playerid, params[])
  340. {
  341.     SpawnPlayer(playerid);
  342.     return 1;
  343. }
  344. ocmd:saveme(playerid, params[])
  345. {
  346.     SpielerSpeichern(playerid);
  347.     return 1;
  348. }
Advertisement
Add Comment
Please, Sign In to add comment