Advertisement
Guest User

Untitled

a guest
Jun 28th, 2014
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 11.93 KB | None | 0 0
  1. //to do list: pustit se do mapy, dodělat další seznamy (motorky, letadla, heli), ZJISTIT POMOCÍ PRINTF, PROČ se jebe klient
  2. #define ZELENA_BARVA 0xFF0000
  3. #define SVETLE_MODRA_BARVA 0xFFFFFF
  4. #define CERVENA_BARVA 0xFF0000FF
  5. #define ZLUTA_BARVA 0xFFFF00FF
  6. #define MODRA_BARVA 0x0000FFAD
  7. #define ORANZOVA_BARVA 0xFFAA00FF
  8. #define SEDA_BARVA 0xBEBEBEFF
  9. #define DIALOG_REGISTER 900
  10. #define DIALOG_LOGIN 901
  11.  
  12. #include <a_samp>
  13. #include <timerfix>
  14.  
  15. new DB:databaze,
  16.     AktualniMapa[6],
  17.     Float:Spawny[30][4],
  18.     PocetMap = 2, //musí být skutečná hodnota -1! po přidání stačí editovat
  19.     KlasickaAuta[158] = {400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 431, 433, 434, 436, 437, 438, 439, 440, 442, 443, 444, 445, 448, 451, 455, 456, 457, 458, 459, 461, 462, 463, 466, 467, 468, 470, 471, 474, 475, 477, 478, 479, 480, 481, 482, 483, 485, 486, 489, 490, 491, 492, 494, 495, 496, 498, 499,
  20.                         500, 502, 503, 504, 505, 506, 507, 508, 509, 510, 514, 515, 516, 517, 518, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 539, 540, 541, 542, 543, 544, 545, 546, 547, 549, 550, 551, 552, 554, 555, 556, 557, 558, 559, 560, 561, 562, 565, 567, 568, 571, 572, 573, 574, 575, 576, 578, 579, 580, 581, 582, 583, 585, 586, 587, 588, 589, 596, 597, 598, 599, 600, 601, 602, 603, 609},
  21.     MotoOnly,
  22.     HeliOnly,
  23.     PlaneOnly;
  24.  
  25. stock strtok(const string[], &index)
  26. {
  27.     new length = strlen(string);
  28.     while ((index < length) && (string[index] <= ' '))
  29.     {
  30.         index++;
  31.     }
  32.  
  33.     new offset = index;
  34.     new result[20];
  35.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  36.     {
  37.         result[index - offset] = string[index];
  38.         index++;
  39.     }
  40.     result[index - offset] = EOS;
  41.     return result;
  42. }
  43.  
  44. Float:GetVal(numb, str[])
  45. {
  46.     new tmp[256], idx;
  47.     for(new i=0; i<numb; i++)
  48.     {
  49.         tmp=strtok (str, idx);
  50.     }
  51.     return floatstr(tmp);
  52. }
  53.  
  54. stock NacistDalsiMapu()
  55. {
  56.     AktualniMapa[0] = random(PocetMap);
  57.     format(AktualniMapa, sizeof(AktualniMapa), "%i.txt", AktualniMapa);
  58.     printf("%s",AktualniMapa);
  59.     new string[128];
  60.     new File:soubor = fopen(AktualniMapa,io_read);
  61.     new Float:data[8];
  62.     new CisloSpawnu = -1;
  63.     while(fread(soubor,string))
  64.     {
  65.         if(strcmp(string, "CreateObject(", true, 13)==0)
  66.         {
  67.             strdel(string,0,13);
  68.             for(new i=0;i<7;i++)
  69.             {
  70.                 data[i] = GetVal(i+1, string);
  71.             }
  72.             CreateObject(floatround(data[0]),data[1],data[2],data[3],data[4],data[5],data[6]);
  73.             printf("CreateObject(%d,%f,%f,%f,%f,%f,%f,0.0);",floatround(data[0]),data[1],data[2],data[3],data[4],data[5],data[6]);
  74.  
  75.             printf("%d",floatround(data[0]));
  76.             printf("%f",data[1]);
  77.             printf("%f",data[2]);
  78.             printf("%f",data[3]);
  79.             printf("%f",data[4]);
  80.             printf("%f",data[5]);
  81.             printf("%f",data[6]);
  82.         }
  83.         else if (strcmp(string, "AddStaticVehicleEx(", true, 19)==0)
  84.         {
  85.             CisloSpawnu++;
  86.             strdel(string,0,19);
  87.             for(new i=0;i<5;i++)
  88.             {
  89.                 data[i] = GetVal(i+1, string);
  90.                 Spawny[CisloSpawnu][0]=data[1]; //X
  91.                 Spawny[CisloSpawnu][1]=data[2]; //Y
  92.                 Spawny[CisloSpawnu][2]=data[3]; //Z
  93.                 Spawny[CisloSpawnu][3]=data[4]; //angle
  94.                 printf("%f",data[1]);
  95.             }
  96.         }
  97.     }
  98.     fclose(soubor);
  99.     return 1;
  100. }
  101.  
  102. stock GetPlayerID(const Name[])
  103. {
  104.     for(new i; i<MAX_PLAYERS; i++)
  105.     {
  106.         if(IsPlayerConnected(i))
  107.         {
  108.             new pName[MAX_PLAYER_NAME];
  109.             GetPlayerName(i, pName, sizeof(pName));
  110.             if(strcmp(Name, pName, true)==0)
  111.             {
  112.             return i;
  113.             }
  114.         }
  115.     }
  116.     return -1;
  117. }
  118.  
  119. stock JmenoHrace(playerid)
  120. {
  121.     new Name[MAX_PLAYER_NAME+1];
  122.     GetPlayerName(playerid, Name, sizeof(Name));
  123.     return Name;
  124. }
  125.  
  126. stock CheckPassword(playerid)
  127. {
  128.     new query[256],DBResult:result,password[24];
  129.     format(query,sizeof(query),"SELECT Heslo FROM Tabulka1 WHERE Nick='%s'",JmenoHrace(playerid));
  130.     result = db_query(databaze,query);
  131.     if(result)
  132.     {
  133.         db_get_field_assoc(result,"Heslo",password,sizeof(password));
  134.         SetPVarString(playerid,"Heslo",password);
  135.     }
  136.     return 1;
  137. }
  138.  
  139. public OnGameModeInit()
  140. {
  141.     databaze = db_open("data.db");
  142.     new DBResult: result;
  143.     result = db_query(databaze,"CREATE TABLE IF NOT EXISTS Tabulka1 (Nick VARCHAR(25), Heslo VARCHAR(15), AdminLevel INTEGER, Death INTEGER, Level INTEGER, Expy INTEGER, Money INTEGER, KoupenaAuta INTEGER, DatumRegistrace INTEGER, PlayTime INTEGER)");
  144.     db_free_result(result);
  145.     SetGameModeText("World Of Sumo 0.1 ALPHA");
  146.     UsePlayerPedAnims();
  147.     NacistDalsiMapu();
  148.     return 1;
  149. }
  150.  
  151. public OnGameModeExit()
  152. {
  153.     return 1;
  154. }
  155.  
  156. public OnPlayerRequestClass(playerid, classid)
  157. {
  158.     return 1;
  159. }
  160.  
  161. public OnPlayerConnect(playerid)
  162. {
  163.     SetPlayerColor(playerid,SEDA_BARVA);
  164.     new DBResult: result;
  165.     new string[256];
  166.     new query[256];
  167.     format(string,sizeof(string),"SELECT * FROM Tabulka1 WHERE Nick='%s'",JmenoHrace(playerid));
  168.     result = db_query(databaze,string);
  169.     format(query,sizeof(query),"'%d'", db_num_rows(result));
  170.     if(db_num_rows(result)==0)
  171.     {
  172.         ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Registrace","Zadejte své heslo:","Ok","");
  173.         db_free_result(result);
  174.     }
  175.     else if(db_num_rows(result)!=0)
  176.     {
  177.         SetPVarInt(playerid,"PocetPokusu",1);
  178.         ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Přihlášení","Zadejte své heslo: (1/3 pokusů)","Ok","");
  179.         db_free_result(result);
  180.     }
  181.     return 1;
  182. }
  183.  
  184. public OnPlayerDisconnect(playerid, reason)
  185. {
  186.     new string[128];
  187.     switch(reason)
  188.     {
  189.         case 0: format(string, sizeof string, "Hráč %s (ID:%i) se odpojil (Time out/crash)",JmenoHrace(playerid),GetPlayerID(JmenoHrace(playerid)));
  190.         case 1: format(string, sizeof string, "Hráč %s (ID:%i) se odpojil",JmenoHrace(playerid),GetPlayerID(JmenoHrace(playerid)));
  191.         case 2: format(string, sizeof string, "Hráč %s (ID:%i) se odpojil (Kick/Ban)",JmenoHrace(playerid),GetPlayerID(JmenoHrace(playerid)));
  192.     }
  193.     SendClientMessageToAll(SEDA_BARVA, string);
  194.     return 1;
  195. }
  196.  
  197. public OnPlayerSpawn(playerid)
  198. {
  199.     return 1;
  200. }
  201.  
  202. public OnPlayerDeath(playerid, killerid, reason)
  203. {
  204.     SendDeathMessage(killerid, playerid, reason);
  205.     return 1;
  206. }
  207.  
  208. public OnVehicleSpawn(vehicleid)
  209. {
  210.     return 1;
  211. }
  212.  
  213. public OnVehicleDeath(vehicleid, killerid)
  214. {
  215.     return 1;
  216. }
  217.  
  218. public OnPlayerText(playerid, text[])
  219. {
  220.     return 1;
  221. }
  222.  
  223. public OnPlayerCommandText(playerid, cmdtext[])
  224. {
  225.     if (strcmp("/kill", cmdtext, true, 10) == 0)
  226.     {
  227.         SetPlayerHealth(playerid,0);
  228.         return 1;
  229.     }
  230.     return 0;
  231. }
  232.  
  233. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  234. {
  235.     return 1;
  236. }
  237.  
  238. public OnPlayerExitVehicle(playerid, vehicleid)
  239. {
  240.     return 1;
  241. }
  242.  
  243. public OnPlayerStateChange(playerid, newstate, oldstate)
  244. {
  245.     return 1;
  246. }
  247.  
  248. public OnPlayerEnterCheckpoint(playerid)
  249. {
  250.     return 1;
  251. }
  252.  
  253. public OnPlayerLeaveCheckpoint(playerid)
  254. {
  255.     return 1;
  256. }
  257.  
  258. public OnPlayerEnterRaceCheckpoint(playerid)
  259. {
  260.     return 1;
  261. }
  262.  
  263. public OnPlayerLeaveRaceCheckpoint(playerid)
  264. {
  265.     return 1;
  266. }
  267.  
  268. public OnRconCommand(cmd[])
  269. {
  270.     return 1;
  271. }
  272.  
  273. public OnPlayerRequestSpawn(playerid)
  274. {
  275.     return 1;
  276. }
  277.  
  278. public OnObjectMoved(objectid)
  279. {
  280.     return 1;
  281. }
  282.  
  283. public OnPlayerObjectMoved(playerid, objectid)
  284. {
  285.     return 1;
  286. }
  287.  
  288. public OnPlayerPickUpPickup(playerid, pickupid)
  289. {
  290.     return 1;
  291. }
  292.  
  293. public OnVehicleMod(playerid, vehicleid, componentid)
  294. {
  295.     return 1;
  296. }
  297.  
  298. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  299. {
  300.     return 1;
  301. }
  302.  
  303. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  304. {
  305.     return 1;
  306. }
  307.  
  308. public OnPlayerSelectedMenuRow(playerid, row)
  309. {
  310.     return 1;
  311. }
  312.  
  313. public OnPlayerExitedMenu(playerid)
  314. {
  315.     return 1;
  316. }
  317.  
  318. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  319. {
  320.     return 1;
  321. }
  322.  
  323. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  324. {
  325.     return 1;
  326. }
  327.  
  328. public OnRconLoginAttempt(ip[], password[], success)
  329. {
  330.     return 1;
  331. }
  332.  
  333. public OnPlayerUpdate(playerid)
  334. {
  335.     return 1;
  336. }
  337.  
  338. public OnPlayerStreamIn(playerid, forplayerid)
  339. {
  340.     return 1;
  341. }
  342.  
  343. public OnPlayerStreamOut(playerid, forplayerid)
  344. {
  345.     return 1;
  346. }
  347.  
  348. public OnVehicleStreamIn(vehicleid, forplayerid)
  349. {
  350.     return 1;
  351. }
  352.  
  353. public OnVehicleStreamOut(vehicleid, forplayerid)
  354. {
  355.     return 1;
  356. }
  357.  
  358. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  359. {
  360.     if(dialogid == DIALOG_REGISTER)
  361.     {
  362.         if(response)
  363.         {
  364.             if(strfind(inputtext,"'")!=-1)
  365.             {
  366.                 SendClientMessage(playerid,CERVENA_BARVA,"Heslo nesmí z bezpečnostních důvodů obsahovat uvozovky!");
  367.                 ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Registrace","Zadejte své heslo:","Ok","");
  368.             }
  369.             else
  370.             {
  371.                 if(strlen(inputtext)<=4||strlen(inputtext)>=16)
  372.                 {
  373.                     SendClientMessage(playerid,CERVENA_BARVA,"Heslo musí mít 5-15 znaků!");
  374.                     ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Registrace","Zadejte své heslo:","Ok","");
  375.                 }
  376.                 else
  377.                 {
  378.                     new query[256];
  379.                     format(query,sizeof(query),"INSERT INTO Tabulka1 (Nick, Heslo, AdminLevel, Death, Level, Expy, Money, KoupenaAuta, DatumRegistrace, PlayTime) VALUES ('%s','%s',0,0,0,0,0,0,0,0)",JmenoHrace(playerid),inputtext);
  380.                     db_query(databaze,query);
  381.                     SendClientMessage(playerid,ZELENA_BARVA,"Zaregistrovali ses");
  382.                     new SePripojil[256];
  383.                     format(SePripojil,sizeof(SePripojil),"Hráč %s (ID:%i) se zaregistroval",JmenoHrace(playerid),GetPlayerID(JmenoHrace(playerid)));
  384.                     SendClientMessageToAll(SEDA_BARVA,SePripojil);
  385.                     ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Přihlášení","Nyní se přihlašte: (1/3 pokusů)","Ok","");
  386.                     SetPVarInt(playerid,"RegILog",1);
  387.                     return 1;
  388.                 }
  389.             }
  390.         }
  391.         if(!response)
  392.         {
  393.             SendClientMessage(playerid,CERVENA_BARVA,"Musíte se zaregistrovat!");
  394.             Kick(playerid);
  395.         }
  396.         return 1;
  397.     }
  398.     if(dialogid == DIALOG_LOGIN)
  399.     {
  400.         if(response)
  401.         {
  402.             new string[15];
  403.             CheckPassword(playerid);
  404.             GetPVarString(playerid,"Heslo",string,sizeof(string));
  405.             new str[50];
  406.             SetPVarInt(playerid,"PocetPokusu",GetPVarInt(playerid,"PocetPokusu")+1);
  407.             format(str,sizeof(str),"Zadejte své heslo: (%i/3 pokusů)",GetPVarInt(playerid,"PocetPokusu"));
  408.             if(strlen(inputtext)==0)
  409.             {
  410.                 SendClientMessage(playerid,CERVENA_BARVA,"Prosím, zadejte své heslo");
  411.                 ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Přihlášení",str,"Ok","");
  412.             }
  413.             else if(!strcmp(string,inputtext,false))
  414.             {
  415.                 SendClientMessage(playerid,ZELENA_BARVA,"Přihlásil ses");
  416.                 SetPlayerTeam(playerid,254);
  417.                 if(GetPVarInt(playerid,"RegILog")!=1)
  418.                 {
  419.                     new SePripojil[128];
  420.                     format(SePripojil,sizeof(SePripojil),"Hráč %s (ID:%i) se připojil",JmenoHrace(playerid),GetPlayerID(JmenoHrace(playerid)));
  421.                     SendClientMessageToAll(SEDA_BARVA,SePripojil);
  422.                 }
  423.             }
  424.             else if(strcmp(string,inputtext,false) !=0)
  425.             {
  426.                 SendClientMessage(playerid,CERVENA_BARVA,"Špatné heslo");
  427.                 ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Přihlášení",str,"Ok","");
  428.                 if(GetPVarInt(playerid,"PocetPokusu")>=4)
  429.                 {
  430.                     SendClientMessage(playerid,CERVENA_BARVA,"Byl jsi vyhozen pro opakované zadávání špatného hesla");
  431.                     Kick(playerid);
  432.                 }
  433.             }
  434.             return 1;
  435.         }
  436.         if(!response)
  437.         {
  438.             SendClientMessage(playerid,CERVENA_BARVA,"Musíte se přihlásit!");
  439.             Kick(playerid);
  440.         }
  441.         return 1;
  442.     }
  443.  
  444.     return 0;
  445. }
  446.  
  447. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  448. {
  449.     return 1;
  450. }
  451.  
  452. public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
  453. {
  454.     return 1;
  455. }
  456.  
  457. public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
  458. {
  459.     if(GetPlayerTeam(playerid)==1||GetPlayerTeam(playerid)==2)
  460.     {
  461.         if(GetPlayerTeam(damagedid)==255&&weaponid==41)
  462.         {
  463.             ApplyAnimation(damagedid,"CRACK","crckidle2",4.1,1,1,1,0,3000,1);
  464.         }
  465.     }
  466.     return 1;
  467. }
  468.  
  469. public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
  470. {
  471.     return 1;
  472. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement