Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 48.10 KB | None | 0 0
  1. /* ========= INFO
  2.     Ðàçðàáîòêà ìîäà Western State.
  3.         Êóðàòîð     - Ðàñèì Ãàäæèåâ
  4.         Ìàïïåð      - Êèðèëë Àëåêñàíäðîâ (Martin)
  5.         Ñêðèïòåð    - Åâãåíèé Êîñîâñêèé (McLuhan)
  6.        
  7. */
  8.  
  9. // ============================================================================= INCLUDE
  10. #include <a_samp>
  11. main() return 1;
  12. #include <a_mysql>
  13. #include <sscanf2>
  14. #include <foreach>
  15. #include <regex>
  16. #include <zcmd>
  17. #include <streamer>
  18.  
  19. // ============================================================================= DEFINE
  20. #define SERVERMODE_OBT
  21. #undef MAX_PLAYERS
  22. #define MAX_PLAYERS (500)
  23.  
  24. #define serverName                                                              "Western State"
  25. #define serverVersion                                                           "v0.3z R1"
  26. #define serverWeburl                                                            "western-state.ru"
  27. #define serverPassword                                                          "1"
  28. #define serverRconPassword                                                      "1"
  29. #define serverMaxPlayers                                                        "50"
  30.  
  31. #define m_host                                                                  "localhost"
  32. #define m_user                                                                  "root"
  33. #define m_base                                                                  "wsrp"
  34. #define m_pass                                                                  ""
  35.  
  36. #define scm(%0,%1)                                                              SendClientMessage(%0,-1,%1)
  37.  
  38. #define SPVI                                                                    SetPVarInt
  39. #define SPVF                                                                    SetPVarFloat
  40. #define SPVS                                                                    SetPVarString
  41. #define GPVI                                                                    GetPVarInt
  42. #define GPVF                                                                    GetPVarFloat
  43. #define GPVS                                                                    GetPVarString
  44. #define DPVAR                                                                   DeletePVar
  45.  
  46. #define colorServer                                                             "EA7500"
  47. #define colorBlack                                                              "000000"
  48. #define colorRed                                                                "FF0000"
  49. #define colorGreen                                                              "00FF00"
  50. #define colorBlue                                                               "0000FF"
  51. #define colorGrey                                                               "C0C0C0"
  52. #define colorWhite                                                              "FFFFFF"
  53. #define colorYellow                                                             "FFFF00"
  54.  
  55. #define isAdmin(%0) pinfo[playerid][padmin]<%0
  56.  
  57. // ============================================================================= ENUM
  58. enum enum_pinfo {
  59.     ORM: pormid,
  60.     bool: plogin,
  61.  
  62.     puid,
  63.     pname[24],
  64.     pemail[128],
  65.     ppass[12],
  66.     pcash,
  67.     pskin,
  68.     plastskin,
  69.     padmin,
  70.     pnational,
  71.     pgender,
  72.     page,
  73.     pstylelife,
  74.     psaveworld,
  75.     psaveint,
  76.     psavepos[55],
  77. };
  78. enum enum_dialog {
  79.     did_nope,
  80.     did_obt,
  81.     did_register
  82. };
  83. enum data_selectStyleLifeEnum { title[15], Float: cam11, Float: cam12, Float: cam13, Float: cam21, Float: cam22, Float: cam23, Float: spawn1, Float: spawn2, Float: spawn3, Float: spawn4 };
  84. // ============================================================================= NEW
  85. new pinfo[MAX_PLAYERS][enum_pinfo];
  86. new CH;
  87. new RegEx: validPass,
  88.     RegEx: validEmail,
  89.     RegEx: validNumber;
  90.  
  91. // ----------------------------------------------------------------------------- register/login
  92. new PlayerText: PTD_registerForm_1[MAX_PLAYERS][17];
  93. new PlayerText: PTD_registerForm_2[MAX_PLAYERS][17];
  94. new PlayerText: PTD_registerForm_3[MAX_PLAYERS][10];
  95. new PlayerText: PTD_registerForm_4[MAX_PLAYERS][8];
  96. new PlayerText: PTD_registerForm_5[MAX_PLAYERS][2];
  97. new PlayerText: PTD_registerForm_6[MAX_PLAYERS][2];
  98. new PlayerText: PTD_loginForm[MAX_PLAYERS][13];
  99. new nationals[5][2][20] = {
  100.     { "Àìåðèêàíåö", "Àìåðèêàíêà" },
  101.     { "Ôðàíöóç", "Ôðàíöóçêà" },
  102.     { "Ðóññêèé", "Ðóññêàÿ" },
  103.     { "Èòàëüÿíåö", "Èòàëüÿíêà" },
  104.     { "ßïîíåö", "ßïîíêà" }
  105. };
  106. new nationalsEnglish[5][15] = { "American", "French", "Russian", "Italian", "Japanese" };
  107. new nationalitySkin[2][5][7] =
  108. {
  109.     {
  110.         {21,    4,      7,      1,  3,  6,  23}, // [Àìåðèêàíåö]
  111.         {143,   142,    221,    -1, -1, -1, -1},  // [Ôðàíöóç]
  112.         {72,    95,     119,    -1, -1, -1, -1}, // [Ðóññêèé]
  113.         {26,    33,     43,     -1, -1, -1, -1}, // [Èòàëüÿíåö]
  114.         {229,   228,    208,    -1, -1, -1, -1} // [ßïîíåö]
  115.     },
  116.     {
  117.         {9,     13,     69,     12, 40, 55, -1}, // [Àìåðèêàíêà]
  118.         {245,   298,    76,     -1, -1, -1, -1}, // [Ôðàíöóçêà]
  119.         {56,    150,    193,    -1, -1, -1, -1}, // [Ðóññêàÿ]
  120.         {40,    85,     91,     -1, -1, -1, -1}, // [Èòàëüÿíêà]
  121.         {224,   225,    -1,     -1, -1, -1, -1} // [ßïîíêà]
  122.     }
  123. };
  124. new data_selectStyleLife[3][data_selectStyleLifeEnum] =
  125. {
  126.     { "Ghetto", 2063.448974, -1822.458251, 30.375446, 2067.439697, -1819.575805, 29.501058, 2096.4199, -1806.9941, 13.5525, 91.6086 },
  127.     { "Urban", 1449.919799, -1307.406005, 85.601577, 1454.718505, -1307.182006, 84.214958, 1539.5706, -1277.1816, 17.4080, 127.3523 },
  128.     { "Village", -192.089843, -1306.870605, 44.474807, -196.593383, -1309.006958, 44.081893, -68.0755, -1586.0383, 2.6172, 226.6800 }
  129. };
  130. new Float: registration_miniatures[18][2][6] = {
  131. // LS:
  132.     {
  133.         {1712.207397, -2286.547851, 22.633438, 1710.341064, -2286.507568, 1.266306},
  134.         {1707.208007, -2286.517089, 22.707973, 1705.368896, -2286.477050, 0.740258}
  135.     },  {
  136.         {1627.109252, -755.498107, 154.925125, 1606.737670, -801.589477, 146.594619},
  137.         {1628.883666, -760.084960, 154.023834, 1608.339843, -806.172546, 145.399276}
  138.     },  {
  139.         {1361.059082, -882.859191, 84.104949, 1426.897094, -878.882202, 84.104949},
  140.         {1360.757812, -877.870849, 84.265075, 1426.595825, -873.893859, 84.265075}
  141.     },  {
  142.         {-296.287048, -1595.629394, 25.176271, -266.253387, -1622.165039, 25.176271},
  143.         {-292.924499, -1591.932739, 25.008335, -262.970672, -1618.393676, 25.196121}
  144.     },  {
  145.         {1626.224487, -1439.455688, 55.927925, 1488.745483, -1432.269165, 148.606231},
  146.         {1624.134033, -1436.580566, 59.444068, 1490.854736, -1429.431762, 152.141769}
  147.     },  {
  148.         {2916.498535, -1628.880249, 18.703788, 2938.121093, -1574.233520, 21.476581},
  149.         {2915.629394, -1623.957519, 18.809249, 2936.547363, -1569.523193, 20.896181}
  150. // LV:
  151.     },  {
  152.         {2112.072021, 1260.443847, 37.979156, 2119.436767, 1180.082397, 109.110282},
  153.         {2116.451660, 1262.470825, 36.671531, 2122.804199, 1183.121826, 107.007164}
  154.     },  {
  155.         {2213.008544, 1887.846069, 35.766742, 2121.373046, 1766.163085, 26.290328},
  156.         {2217.265625, 1885.233154, 35.540576, 2125.559326, 1768.879882, 25.982250}
  157.     },  {
  158.         {2169.038818, 954.359375, 157.635604, 2066.023681, 922.612487, 167.732192},
  159.         {2169.012939, 959.307800, 156.919647, 2063.517333, 926.352722, 165.557647}
  160.     },  {
  161.         {1724.389404, 390.285888, 59.728694, 1762.666381, 511.557708, 47.103473},
  162.         {1724.116699, 395.251037, 59.206214, 1761.723876, 516.427368, 46.472351}
  163.     },  {
  164.         {928.612792, 2626.731445, 26.005752, 961.734985, 2566.655761, 11.089242},
  165.         {931.983459, 2623.050292, 26.302455, 965.996093, 2564.410888, 12.432239}
  166.     },  {
  167.         {-49.069660, 2176.562988, 147.759994, -47.282554, 2005.574951, 180.394912},
  168.         {-53.151138, 2179.437500, 147.479217, -52.219066, 2005.609375, 179.601409}
  169. // SF:
  170.     },  {
  171.         {-1936.008544, 2016.041015, 79.002693, -2069.614257, 2137.992919, 78.872596},
  172.         {-1935.872802, 2021.036254, 78.831169, -2068.558593, 2142.871337, 79.165718}
  173.     },  {
  174.         {-2681.882568, 2559.457275, 96.862686, -2678.370849, 2449.347656, 84.525177},
  175.         {-2677.403320, 2561.678710, 96.824836, -2674.033691, 2447.715576, 82.647781}
  176.     },  {
  177.         {-2500.986328, 2066.782226, 13.977483, -2553.708740, 1782.968139, 5.930901},
  178.         {-2503.990966, 2063.195312, 15.739585, -2555.907714, 1778.785278, 7.564413}
  179.     },  {
  180.         {-2975.291259, 1215.493896, 45.357460, -2984.165527, 1117.990966, 78.488029},
  181.         {-2971.692626, 1212.044677, 44.967548, -2980.832763, 1114.427368, 77.395668}
  182.     },  {
  183.         {-2139.581054, 962.821228, 225.942672, -1984.992309, 708.513122, 193.720321},
  184.         {-2135.511962, 960.069152, 225.010971, -1980.623535, 710.925781, 193.415817}
  185.     },  {
  186.         {-1890.458496, -653.781555, 81.883850, -1890.880859, -847.303466, 74.221061},
  187.         {-1892.749877, -658.203002, 81.436439, -1893.033935, -851.814392, 74.347259}
  188.     }
  189. };
  190. new Float: registration_miniaturesplayer[3][2][6] = {
  191.     {
  192.         {2086.109619, -1816.810668, 14.645484, 2099.914306, -1806.895996, 14.327500},
  193.         {2090.058349, -1813.744506, 14.723714, 2094.922607, -1807.036132, 14.077604}
  194.     }{
  195.         {1540.544311, -1291.160644, 18.894159, 1542.349243, -1275.061157, 18.182899},
  196.         {1540.343750, -1286.166625, 18.753999, 1538.379638, -1278.090942, 17.933004}
  197.     }{
  198.         {-54.170108, -1590.112915, 3.272075, -70.618698, -1583.640258, 3.392100},
  199.         {-59.035842, -1588.966430, 3.170809, -66.985580, -1587.066284, 3.142204}
  200.     }
  201. };
  202. new player_rand_miniatures[MAX_PLAYERS][7];
  203. // ----------------------------------------------------------------------------- register/login
  204.  
  205. public OnGameModeInit()
  206. {
  207.     for(new i; i < 300; i++) AddPlayerClass(i, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  208.     DisableInteriorEnterExits();
  209.     EnableStuntBonusForAll(0);
  210.     mysql_log(LOG_ERROR | LOG_WARNING | LOG_DEBUG, LOG_TYPE_TEXT);
  211.     CH = mysql_connect(m_host, m_user, m_base, m_pass);
  212.     mysql_function_query(CH, "SET NAMES cp1251;", false, "", "");
  213.     mysql_function_query(CH, "SET SESSION character_set_server = cp1251;", false, "", "");
  214.  
  215.     SendRconCommand("hostname (RP) "serverName" | "serverVersion"");
  216.     SendRconCommand("gamemodetext Role Play");
  217.     SendRconCommand("mapname San Andreas");
  218.     SendRconCommand("weburl "serverWeburl"");
  219.     SendRconCommand("rcon_password "serverRconPassword"");
  220.    
  221.     validPass = regex_build("[0-9A-Za-z]{4,12}");
  222.     validEmail = regex_build("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?");
  223.     validNumber = regex_build("[0-9]{1,30}");
  224.     #include <objects>
  225.     #include <textdraws>
  226.  
  227.     SetTimer("timer", 1000, 1);
  228.     return 1;
  229. }
  230.  
  231. public OnGameModeExit()
  232. {
  233.     return 1;
  234. }
  235.  
  236. public OnPlayerRequestClass(playerid, classid)
  237. {
  238.     if(pinfo[playerid][plogin])
  239.     {
  240.         SetSpawnInfo(playerid,0,0,0.0,0.0,0.0,0.0,0,0,0,0,0,0);
  241.         SpawnPlayer(playerid);
  242.     }
  243.     setPlayerWorld(playerid, playerid+3000);
  244.     SetPlayerTime(playerid, random(23), 0);
  245.     for(new i = 0; i < 21; i++) scm(playerid, " ");
  246.     TogglePlayerSpectating(playerid, 1);
  247.     #if defined SERVERMODE_OBT
  248.     ShowPlayerDialog(playerid, did_obt, DIALOG_STYLE_INPUT, " ", " ", " _ ", "");
  249.     scm(playerid, "{"colorRed"}(12) sec");
  250.     SPVI(playerid, "pass_obt_sec", 13);
  251.     #else
  252.     SPVI(playerid, "registration_loading", 13);
  253.     #endif
  254.     return 1;
  255. }
  256.  
  257. public OnPlayerConnect(playerid)
  258. {
  259.     pinfo[playerid][plogin] = false;
  260.  
  261.     pinfo[playerid][puid] = 0;
  262.     GetPlayerName(playerid, pinfo[playerid][pname], 24);
  263.     strdel(pinfo[playerid][pemail], 0, 128);
  264.     strdel(pinfo[playerid][ppass], 0, 18);
  265.     pinfo[playerid][pcash] = 0;
  266.     pinfo[playerid][pskin] = 0;
  267.     pinfo[playerid][plastskin] = 0;
  268.     pinfo[playerid][padmin] = 0;
  269.     pinfo[playerid][pnational] = 0;
  270.     pinfo[playerid][pgender] = 0;
  271.     pinfo[playerid][page] = 0;
  272.     pinfo[playerid][pstylelife] = 0;
  273.     pinfo[playerid][psaveworld] = 0;
  274.     pinfo[playerid][psaveint] = 0;
  275.     strdel(pinfo[playerid][psavepos], 0, 55);
  276.    
  277.     #include <removeObjects>
  278.     return 1;
  279. }
  280.  
  281. public OnPlayerDisconnect(playerid, reason)
  282. {
  283.     if(pinfo[playerid][plogin])
  284.     {
  285.         pinfo[playerid][psaveworld] = getPlayerWorld(playerid);
  286.         pinfo[playerid][psaveint] = getPlayerInt(playerid);
  287.         new Float: pos[4];
  288.         GetPlayerPos(playerid, pos[0], pos[1], pos[2]), GetPlayerFacingAngle(playerid, pos[3]);
  289.         format(pinfo[playerid][psavepos], 55, "%f,%f,%f,%f", pos[0], pos[1], pos[2], pos[3]);
  290.         orm_update(pinfo[playerid][pormid]);
  291.     }
  292.     else
  293.     {
  294.         if(GPVI(playerid, "registration_step") == 1) for(new i = 0; i < 17; i++) PlayerTextDrawDestroy(playerid, PTD_registerForm_1[playerid][i]);
  295.         if(GPVI(playerid, "registration_step") == 2) for(new i = 0; i < 17; i++) PlayerTextDrawDestroy(playerid, PTD_registerForm_2[playerid][i]);
  296.         if(GPVI(playerid, "registration_step") == 3) for(new i = 0; i < 10; i++) PlayerTextDrawDestroy(playerid, PTD_registerForm_3[playerid][i]);
  297.         if(GPVI(playerid, "registration_step") == 4) for(new i = 0; i < 8; i++) PlayerTextDrawDestroy(playerid, PTD_registerForm_4[playerid][i]);
  298.         if((GPVI(playerid, "registration_step") == 5) && (GPVI(playerid, "registration_miniaturestep") < 9) && (GPVI(playerid, "registration_miniaturestep") > 5)) for(new i = 0; i < 2; i++) PlayerTextDrawDestroy(playerid, PTD_registerForm_5[playerid][i]);
  299.         if((GPVI(playerid, "registration_step") == 5) && (GPVI(playerid, "registration_miniaturestep") == 9)) for(new i = 0; i < 2; i++) PlayerTextDrawDestroy(playerid, PTD_registerForm_6[playerid][i]);
  300.     }
  301.     orm_destroy(pinfo[playerid][pormid]);
  302.     return 1;
  303. }
  304.  
  305. public OnPlayerSpawn(playerid)
  306. {
  307.     if(GPVI(playerid, "registration_step") == 5)
  308.     {
  309.         setPlayerSkin(playerid, pinfo[playerid][pskin]);
  310.         new style = pinfo[playerid][pstylelife];
  311.         setPlayerPos(playerid, data_selectStyleLife[style-1][spawn1], data_selectStyleLife[style-1][spawn2], data_selectStyleLife[style-1][spawn3], data_selectStyleLife[style-1][spawn4]);
  312.         for(new i = 0; i < 2; i++) PlayerTextDrawDestroy(playerid, PTD_registerForm_5[playerid][i]);
  313.         createPTDRegister_6(playerid);
  314.         SPVI(playerid, "registration_miniature", gettime()+9);
  315.         SPVI(playerid, "registration_miniaturestep", 9);
  316.         TogglePlayerControllable(playerid, 0);
  317.         setPlayerWorld(playerid, playerid+3000);
  318.         new val = pinfo[playerid][pstylelife]-1;
  319.         InterpolateCameraPos(playerid, registration_miniaturesplayer[val][0][0], registration_miniaturesplayer[val][0][1], registration_miniaturesplayer[val][0][2], registration_miniaturesplayer[val][0][3], registration_miniaturesplayer[val][0][4], registration_miniaturesplayer[val][0][5], 7500);
  320.         InterpolateCameraLookAt(playerid, registration_miniaturesplayer[val][1][0], registration_miniaturesplayer[val][1][1], registration_miniaturesplayer[val][1][2], registration_miniaturesplayer[val][1][3], registration_miniaturesplayer[val][1][4], registration_miniaturesplayer[val][1][5], 7500);
  321.     }
  322.     if(!pinfo[playerid][plogin]) return 1;
  323.     new Float: pos[4];
  324.     sscanf(pinfo[playerid][psavepos], "p<,>ffff", pos[0], pos[1], pos[2], pos[3]);
  325.     setPlayerPos(playerid, pos[0], pos[1], pos[2], pos[3]);
  326.     setPlayerSkin(playerid, pinfo[playerid][pskin]);
  327.     setPlayerInt(playerid, pinfo[playerid][psaveint]);
  328.     setPlayerWorld(playerid, pinfo[playerid][psaveworld]);
  329.     GivePlayerWeapon(playerid, 43, 999);
  330.     scm(playerid, "{"colorGrey"}(âðåìåííàÿ ìåññàãà) /ucmds /acmds /tcmds");
  331.     return 1;
  332. }
  333.  
  334. public OnPlayerDeath(playerid, killerid, reason)
  335. {
  336.     pinfo[playerid][psaveworld] = getPlayerWorld(playerid);
  337.     pinfo[playerid][psaveint] = getPlayerInt(playerid);
  338.     new Float: pos[4];
  339.     GetPlayerPos(playerid, pos[0], pos[1], pos[2]), GetPlayerFacingAngle(playerid, pos[3]);
  340.     format(pinfo[playerid][psavepos], 55, "%f,%f,%f,%f", pos[0], pos[1], pos[2], pos[3]);
  341.     orm_update(pinfo[playerid][pormid]);
  342.     return 1;
  343. }
  344.  
  345. public OnVehicleSpawn(vehicleid)
  346. {
  347.     return 1;
  348. }
  349.  
  350. public OnVehicleDeath(vehicleid, killerid)
  351. {
  352.     return 1;
  353. }
  354.  
  355. public OnPlayerText(playerid, text[])
  356. {
  357.     if(GPVI(playerid, "kicktime") > 0) return 0;
  358.     if(!pinfo[playerid][plogin]) { scm(playerid, "{"colorGrey"}Âû íå àâòîðèçèðîâàíû."); return 0; }
  359.     return 1;
  360. }
  361.  
  362. public OnPlayerCommandText(playerid, cmdtext[])
  363. {
  364.     return 1;
  365. }
  366.  
  367. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  368. {
  369.     return 1;
  370. }
  371.  
  372. public OnPlayerExitVehicle(playerid, vehicleid)
  373. {
  374.     return 1;
  375. }
  376.  
  377. public OnPlayerStateChange(playerid, newstate, oldstate)
  378. {
  379.     return 1;
  380. }
  381.  
  382. public OnPlayerEnterCheckpoint(playerid)
  383. {
  384.     return 1;
  385. }
  386.  
  387. public OnPlayerLeaveCheckpoint(playerid)
  388. {
  389.     return 1;
  390. }
  391.  
  392. public OnPlayerEnterRaceCheckpoint(playerid)
  393. {
  394.     return 1;
  395. }
  396.  
  397. public OnPlayerLeaveRaceCheckpoint(playerid)
  398. {
  399.     return 1;
  400. }
  401.  
  402. public OnRconCommand(cmd[])
  403. {
  404.     return 1;
  405. }
  406.  
  407. public OnPlayerRequestSpawn(playerid)
  408. {
  409.     return 1;
  410. }
  411.  
  412. public OnDynamicObjectMoved(objectid)
  413. {
  414.     return 1;
  415. }
  416.  
  417. public OnPlayerObjectMoved(playerid, objectid)
  418. {
  419.     return 1;
  420. }
  421.  
  422. public OnPlayerPickUpDynamicPickup(playerid, pickupid)
  423. {
  424.     return 1;
  425. }
  426.  
  427. public OnPlayerPickUpPickup(playerid, pickupid)
  428. {
  429.     return 1;
  430. }
  431.  
  432. public OnVehicleMod(playerid, vehicleid, componentid)
  433. {
  434.     return 1;
  435. }
  436.  
  437. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  438. {
  439.     return 1;
  440. }
  441.  
  442. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  443. {
  444.     return 1;
  445. }
  446.  
  447. public OnPlayerSelectedMenuRow(playerid, row)
  448. {
  449.     return 1;
  450. }
  451.  
  452. public OnPlayerExitedMenu(playerid)
  453. {
  454.     return 1;
  455. }
  456.  
  457. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  458. {
  459.     return 1;
  460. }
  461.  
  462. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  463. {
  464.     return 1;
  465. }
  466.  
  467. public OnRconLoginAttempt(ip[], password[], success)
  468. {
  469.     return 1;
  470. }
  471.  
  472. public OnPlayerUpdate(playerid)
  473. {
  474.     return 1;
  475. }
  476.  
  477. public OnPlayerStreamIn(playerid, forplayerid)
  478. {
  479.     return 1;
  480. }
  481.  
  482. public OnPlayerStreamOut(playerid, forplayerid)
  483. {
  484.     return 1;
  485. }
  486.  
  487. public OnVehicleStreamIn(vehicleid, forplayerid)
  488. {
  489.     return 1;
  490. }
  491.  
  492. public OnVehicleStreamOut(vehicleid, forplayerid)
  493. {
  494.     return 1;
  495. }
  496.  
  497. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  498. {
  499.     switch(dialogid)
  500.     {
  501.         case did_obt:
  502.         {
  503.             if(strcmp(inputtext, serverPassword, false) || !strlen(inputtext)) { scm(playerid, "{"colorRed"}Password is not correct."), kick(playerid), DPVAR(playerid, "pass_obt_sec"); return 1; }
  504.             SPVI(playerid, "registration_loading", 13);
  505.             scm(playerid, "{"colorGreen"}Password correct.");
  506.             DPVAR(playerid, "pass_obt_sec");
  507.             return 1;
  508.         }
  509.         case did_register:
  510.         {
  511.             if((GPVI(playerid, "login_step") > 0) && (GPVI(playerid, "login_form") == 2))
  512.             {
  513.                 if(strlen(inputtext) < 4 || strlen(inputtext) > 12) return ShowPlayerDialog(playerid, did_register, DIALOG_STYLE_INPUT, " ", "{"colorRed"}âû ââåëè ñëèøêîì ìàëî èëè ñëèøêîì ìíîãî ñèìâîëîâ (4-12)", " ", "");
  514.                 PlayerTextDrawSetString(playerid, PTD_loginForm[playerid][8], inputtext);
  515.                 SPVS(playerid, "login_pass", inputtext);
  516.                 DPVAR(playerid, "login_form");
  517.                 return 1;
  518.             }
  519.             if((GPVI(playerid, "registration_step") == 1) && ((GPVI(playerid, "registration_form") == 2) || (GPVI(playerid, "registration_form") == 3)))
  520.             {
  521.                 if(!regex_match_exid(inputtext, (GPVI(playerid, "registration_form") == 2) ? (validPass) : (validEmail))) return ShowPlayerDialog(playerid, did_register, DIALOG_STYLE_INPUT, " ", (GPVI(playerid, "registration_form") == 2) ? ("\tïðèìåð ïàðîëÿ: oK5lWaNKa40Q\n\t\t{"colorRed"}âàëèäíîñòü ïàðîëÿ íå ïðàâèëüíàÿ") : ("\tïðèìåð email: support@westernstate.ru\n\t\t{"colorRed"}âàëèäíîñòü email íå ïðàâèëüíàÿ"), " ", "");
  522.                 PlayerTextDrawSetString(playerid, (GPVI(playerid, "registration_form") == 2) ? (PTD_registerForm_1[playerid][11]) : (PTD_registerForm_1[playerid][12]), inputtext);
  523.                 if(GPVI(playerid, "registration_form") == 2) strmid(pinfo[playerid][ppass], inputtext, 0, strlen(inputtext), 12);
  524.                 else if(GPVI(playerid, "registration_form") == 3) strmid(pinfo[playerid][pemail], inputtext, 0, strlen(inputtext), 128);
  525.                 SelectTextDraw(playerid, 0xEA7500ff), DPVAR(playerid, "registration_form");
  526.                 for(new c = 0; c < 21; c++) scm(playerid, " ");
  527.                 scm(playerid, "{"colorServer"}Western State | ýòàï 1");
  528.                 scm(playerid, "{"colorGreen"}Åñëè âû çàïîëíèëè âñå ïîëÿ, íàæìèòå CONTINUE!");
  529.                 return 1;
  530.             }
  531.             else if((GPVI(playerid, "registration_step") == 2) && ((GPVI(playerid, "registration_form") == 1) || (GPVI(playerid, "registration_form") == 2) || (GPVI(playerid, "registration_form") == 3)))
  532.             {
  533.                 if(GPVI(playerid, "registration_form") == 1)
  534.                 {
  535.                     pinfo[playerid][pgender] = listitem+1;
  536.                     PlayerTextDrawSetString(playerid, PTD_registerForm_2[playerid][10], (listitem == 0) ? ("Man") : ("Woman"));
  537.                     if(pinfo[playerid][pnational] > 0)
  538.                     {
  539.                         pinfo[playerid][pnational] = 0;
  540.                         PlayerTextDrawSetString(playerid, PTD_registerForm_2[playerid][11], "SET");
  541.                     }
  542.                     for(new c = 0; c < 21; c++) scm(playerid, " ");
  543.                     scm(playerid, "{"colorServer"}Western State | ýòàï 2");
  544.                     scm(playerid, "{"colorGreen"}Åñëè âû çàïîëíèëè âñå ïîëÿ, íàæìèòå CONTINUE!");
  545.                 }
  546.                 if(GPVI(playerid, "registration_form") == 2)
  547.                 {
  548.                     pinfo[playerid][pnational] = listitem+1;
  549.                     PlayerTextDrawSetString(playerid, PTD_registerForm_2[playerid][11], nationalsEnglish[listitem]);
  550.                     for(new c = 0; c < 21; c++) scm(playerid, " ");
  551.                     scm(playerid, "{"colorServer"}Western State | ýòàï 2");
  552.                     scm(playerid, "{"colorGreen"}Åñëè âû çàïîëíèëè âñå ïîëÿ, íàæìèòå CONTINUE!");
  553.                 }
  554.                 if(GPVI(playerid, "registration_form") == 3)
  555.                 {
  556.                     if(!regex_match_exid(inputtext, validNumber) || strval(inputtext) < 22 || strval(inputtext) > 45) return ShowPlayerDialog(playerid, did_register, DIALOG_STYLE_INPUT, " ", "\t{"colorRed"}âîçðàñò ìîæåò áûòü îò 22 äî 45 ëåò", " ", "");
  557.                     pinfo[playerid][page] = strval(inputtext);
  558.                     PlayerTextDrawSetString(playerid, PTD_registerForm_2[playerid][12], inputtext);
  559.                     for(new c = 0; c < 21; c++) scm(playerid, " ");
  560.                     scm(playerid, "{"colorServer"}Western State | ýòàï 2");
  561.                     scm(playerid, "{"colorGreen"}Åñëè âû çàïîëíèëè âñå ïîëÿ, íàæìèòå CONTINUE!");
  562.                 }
  563.                 SelectTextDraw(playerid, 0xEA7500ff), DPVAR(playerid, "registration_form");
  564.                 return 1;
  565.             }
  566.             return 1;
  567.         }
  568.     }
  569.     return 1;
  570. }
  571.  
  572. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  573. {
  574.     return 1;
  575. }
  576.  
  577. public OnPlayerClickTextDraw(playerid, Text:clickedid)
  578. {
  579.     return 1;
  580. }
  581.  
  582. public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
  583. {
  584.     if(pinfo[playerid][plogin]) return 1;
  585.     if(GPVI(playerid, "login_step") > 0)
  586.     {
  587.         if(GPVI(playerid, "login_form") > 0) return 1;
  588.         if(!(_:playertextid ^ 0xFFFF)) return SelectTextDraw(playerid, 0xEA7500ff);
  589.         else if(playertextid == PTD_loginForm[playerid][11])
  590.         {
  591.             for(new i = 0; i < 13; i++) PlayerTextDrawDestroy(playerid, PTD_loginForm[playerid][i]);
  592.             kick(playerid);
  593.             return 1;
  594.         }
  595.         else if(playertextid == PTD_loginForm[playerid][9])
  596.         {
  597.             new inputpass[13];
  598.             GPVS(playerid, "login_pass", inputpass, 13);
  599.             for(new c = 0; c < 21; c++) scm(playerid, " ");
  600.             if(!strlen(inputpass)) return ShowPlayerDialog(playerid, did_nope, DIALOG_STYLE_MSGBOX, " ", "\t{"colorRed"}çàïîëíèòå âñå ïîëÿ", " ", "");
  601.             if(!strcmp(inputpass, pinfo[playerid][ppass]))
  602.             {
  603.                 StopAudioStreamForPlayer(playerid);
  604.                 new string[24+80];
  605.                 format(string, sizeof string, "{"colorServer"}%s, âû óñïåøíî àâòîðèçèðîâàëèñü íà ñåðâåðå Western State.", pinfo[playerid][pname]);
  606.                 scm(playerid, string);
  607.                 scm(playerid, "{"colorGreen"}Óäà÷íîé èãðû!");
  608.                 setPlayerWorld(playerid, 0);
  609.                 orm_update(pinfo[playerid][pormid]);
  610.                 pinfo[playerid][plogin] = true;
  611.                 DPVAR(playerid, "login_step");
  612.                 DPVAR(playerid, "login_pass");
  613.                 TogglePlayerSpectating(playerid, 0);
  614.                 SpawnPlayer(playerid);
  615.                 for(new i = 0; i < 13; i++) PlayerTextDrawDestroy(playerid, PTD_loginForm[playerid][i]);
  616.                 CancelSelectTextDraw(playerid);
  617.                 return 1;
  618.             }
  619.             else
  620.             {
  621.                 new string[24+80];
  622.                 format(string, sizeof string, "{"colorWhite"}Ïàðîëü {"colorRed"}%s {"colorWhite"}íåïðàâèëüíûé.", inputpass);
  623.                 scm(playerid, string);
  624.                 scm(playerid, "{"colorGreen"}Ââåäèòå ïðàâèëüíûé ïàðîëü.");
  625.             }
  626.         }
  627.         else if(playertextid == PTD_loginForm[playerid][2])
  628.         {
  629.             SPVI(playerid, "login_form", 2);
  630.             ShowPlayerDialog(playerid, did_register, DIALOG_STYLE_INPUT, " ", " ", " ", "");
  631.             return 1;
  632.         }
  633.         return 1;
  634.     }
  635.     else if(GPVI(playerid, "registration_step") > 0)
  636.     {
  637.         if(GPVI(playerid, "registration_step") == 1)
  638.         {
  639.             if(GPVI(playerid, "registration_form") > 0) return 1;
  640.             if(!(_:playertextid ^ 0xFFFF)) return SelectTextDraw(playerid, 0xEA7500ff);
  641.             else if(playertextid == PTD_registerForm_1[playerid][15])
  642.             {
  643.                 for(new i = 0; i < 17; i++) PlayerTextDrawDestroy(playerid, PTD_registerForm_1[playerid][i]);
  644.                 kick(playerid);
  645.                 return 1;
  646.             }
  647.             else if(playertextid == PTD_registerForm_1[playerid][13])
  648.             {
  649.                 if((strlen(pinfo[playerid][ppass]) < 2) || (strlen(pinfo[playerid][pemail]) < 2)) return ShowPlayerDialog(playerid, did_nope, DIALOG_STYLE_MSGBOX, " ", "\t{"colorRed"}çàïîëíèòå âñå ïîëÿ", " ", "");
  650.                 for(new i = 0; i < 17; i++) PlayerTextDrawDestroy(playerid, PTD_registerForm_1[playerid][i]);
  651.                 SPVI(playerid, "registration_step", 2);
  652.                 createPTDRegister_2(playerid);
  653.                 for(new c = 0; c < 21; c++) scm(playerid, " ");
  654.                 scm(playerid, "{"colorServer"}Western State | ýòàï 2");
  655.                 scm(playerid, "{"colorGreen"}Òóò âàì íåîáõîäèìî âûáðàòü ïîë, íàöèîíàëüíîñòü è âîçðàñò ñâîåãî ïåðñîíàæà.");
  656.                 return 1;
  657.             }
  658.             for(new t = 2; t < 4; t++)
  659.             {
  660.                 if(playertextid == PTD_registerForm_1[playerid][t])
  661.                 {
  662.                     for(new c = 0; c < 21; c++) scm(playerid, " ");
  663.                     scm(playerid, "{"colorServer"}Western State | ýòàï 1");
  664.                     if(t == 2)
  665.                     {
  666.                         scm(playerid, "{"colorGreen"}Ïàðîëü äîëæåí ñîñòîÿòü èç ëàòèíñêèõ áóêâ è ñîäåðæàòü íå ìåíåå 4 ñèìâîëîâ.");
  667.                         scm(playerid, "{"colorGreen"}Ïðèìåð: Alex227");
  668.                     }
  669.                     else if(t == 3)
  670.                     {
  671.                         scm(playerid, "{"colorGreen"}Óêàæèòå ñâîþ ýëåêòðîííóþ ïî÷òó, ïîæàëóéñòà óêàçûâàéòå å¸ ïðàâèëüíî!");
  672.                         scm(playerid, "{"colorGreen"} ñëó÷àå ïîòåðè êîíòðîëÿ íàä àêêàóíòîì, íà íå¸ áóäåò âûñëàí ñåêðåòíûé êîä.");
  673.                     }
  674.                     SPVI(playerid, "registration_form", t);
  675.                     ShowPlayerDialog(playerid, did_register, DIALOG_STYLE_INPUT, " ", " ", " ", "");
  676.                     break;
  677.                 }
  678.             }
  679.         }
  680.         else if(GPVI(playerid, "registration_step") == 2)
  681.         {
  682.             if(GPVI(playerid, "registration_form") > 0) return 1;
  683.             if(!(_:playertextid ^ 0xFFFF)) return SelectTextDraw(playerid, 0xEA7500ff);
  684.             else if(playertextid == PTD_registerForm_2[playerid][15])
  685.             {
  686.                 for(new i = 0; i < 17; i++) PlayerTextDrawDestroy(playerid, PTD_registerForm_2[playerid][i]);
  687.                 kick(playerid);
  688.                 return 1;
  689.             }
  690.             else if(playertextid == PTD_registerForm_2[playerid][13])
  691.             {
  692.                 if(!pinfo[playerid][pnational] || !pinfo[playerid][pgender] || !pinfo[playerid][page]) return ShowPlayerDialog(playerid, did_nope, DIALOG_STYLE_MSGBOX, " ", "\t{"colorRed"}çàïîëíèòå âñå ïîëÿ", " ", "");
  693.                 for(new i = 0; i < 17; i++) PlayerTextDrawDestroy(playerid, PTD_registerForm_2[playerid][i]);
  694.                 SPVI(playerid, "registration_step", 3);
  695.                 createPTDRegister_3(playerid);
  696.                 pinfo[playerid][pstylelife] = 1;
  697.                 SetPlayerCameraPos(playerid, data_selectStyleLife[0][cam11], data_selectStyleLife[0][cam12], data_selectStyleLife[0][cam13]);
  698.                 SetPlayerCameraLookAt(playerid, data_selectStyleLife[0][cam21], data_selectStyleLife[0][cam22], data_selectStyleLife[0][cam23]);
  699.                 for(new c = 0; c < 21; c++) scm(playerid, " ");
  700.                 scm(playerid, "{"colorServer"}Western State | ýòàï 3");
  701.                 scm(playerid, "{"colorGreen"}Â ýòîì îêíå âû äîëæíû âûáðàòü áóäóùèé ñòèëü æèçíè âàøåãî ïåðñîíàæà.");
  702.                 scm(playerid, "{"colorGreen"}Âûáîð âëèÿåò íå òîëüêî íà ìåñòî ñïàâíà, íî è íà æèçíåííûå êà÷åñòâà, íàïðèìåð òàêèå êàê ñïîñîáíîñòè ïåðñîíàæà.");
  703.                 scm(playerid, "{"colorGreen"}");
  704.                 scm(playerid, "{"colorGreen"}Ïðàâèëüíûé âûáîð ïîçâîëèò âàì îáëåã÷èòü äîñòèæåíèå îïðåäåë¸ííîé ðîëè íà ñåðâåðå. Õîòèòå áûòü ãàíãñòåðîì? - Âûáèðàéòå ãåòòî.");
  705.                 scm(playerid, "{"colorGreen"}Ñòàòü ìýðîì ãîðîäà ïîìîæåò ðàñïîëîæåíèå â öåíòðå, à ëó÷øèì ðàáîòíèêîì ôåðìû ñòàíåò æèòåëü èç ïðèãîðîäà.");
  706.                 return 1;
  707.             }
  708.             for(new t = 1; t < 4; t++)
  709.             {
  710.                 if(playertextid == PTD_registerForm_2[playerid][t])
  711.                 {
  712.                     for(new c = 0; c < 21; c++) scm(playerid, " ");
  713.                     scm(playerid, "{"colorServer"}Western State | ýòàï 2");
  714.                     if(t == 2)
  715.                     {
  716.                         if(!pinfo[playerid][pgender]) return ShowPlayerDialog(playerid, did_nope, DIALOG_STYLE_MSGBOX, " ", "\t{"colorRed"}ñíà÷àëà âûáåðèòå âàø ïîë", " ", "");
  717.                         new string[144], str[25];
  718.                         for(new i = 0; i < 5; i++) format(str, sizeof str, "%i. %s\n", i+1, nationals[i][pinfo[playerid][pgender]-1]), strcat(string, str);
  719.                         ShowPlayerDialog(playerid, did_register, DIALOG_STYLE_LIST, " ", string, " ", "");
  720.                         SPVI(playerid, "registration_form", 2);
  721.                         scm(playerid, "{"colorGreen"}Íàöèîíàëüíîñòü âëèÿåò íà çíàíèå îïðåäåë¸ííîãî ÿçûêà, à òàê æå îòíîøåíèþ ê îïðåäåë¸ííîìó îáùåñòâó.");
  722.                     }
  723.                     else
  724.                     {
  725.                         if(t == 3) scm(playerid, "{"colorGreen"}Âîçðàñò ïåðñîíàæà äîëæåí áûòü óêàçàí â ïðåäåëàõ îò 22 äî 45 ëåò.");
  726.                         SPVI(playerid, "registration_form", t);
  727.                         ShowPlayerDialog(playerid, did_register, (t == 1) ? (DIALOG_STYLE_LIST) : (DIALOG_STYLE_INPUT), " ", (t == 1) ? ("1. Ìóæ÷èíà\n2. Æåíùèíà") : (" "), " ", "");
  728.                     }
  729.                     break;
  730.                 }
  731.             }
  732.         }
  733.         else if(GPVI(playerid, "registration_step") == 3)
  734.         {
  735.             if(!(_:playertextid ^ 0xFFFF)) return SelectTextDraw(playerid, 0xEA7500ff);
  736.             else if(playertextid == PTD_registerForm_3[playerid][8])
  737.             {
  738.                 for(new i = 0; i < 10; i++) PlayerTextDrawDestroy(playerid, PTD_registerForm_3[playerid][i]);
  739.                 kick(playerid);
  740.                 return 1;
  741.             }
  742.             else if(playertextid == PTD_registerForm_3[playerid][6])
  743.             {
  744.                 for(new i = 0; i < 10; i++) PlayerTextDrawDestroy(playerid, PTD_registerForm_3[playerid][i]);
  745.                 pinfo[playerid][pskin] = nationalitySkin[pinfo[playerid][pgender]-1][pinfo[playerid][pnational]-1][0];
  746.                 SPVI(playerid, "registration_step", 4);
  747.                 SPVI(playerid, "registration_skinval", 0);
  748.                 createPTDRegister_4(playerid);
  749.                 for(new c = 0; c < 21; c++) scm(playerid, " ");
  750.                 scm(playerid, "{"colorServer"}Western State | ýòàï 4");
  751.                 scm(playerid, "{"colorGreen"}Ôèíèøíàÿ ïðÿìàÿ ïåðåä íà÷àëîì èãðû, âàì îñòà¸òñÿ âûáðàòü âíåøíèé îáëèê ñâîåãî ïåðñîíàæà.");
  752.                 scm(playerid, "{"colorGreen"}Êàæäûé ñêèí íàäåë¸í ñâîèìè îñîáåííîñòÿìè.");
  753.                 scm(playerid, "{"colorGreen"}");
  754.                 scm(playerid, "{"colorGreen"}Íàì îñòà¸òñÿ ëèøü ïîæåëàòü âàì óäà÷è â èãðå! Ñïàñèáî, ÷òî âû ñ íàìè!");
  755.                 scm(playerid, "{"colorGreen"}_________________________________");
  756.                 return 1;
  757.             }
  758.             if(playertextid == PTD_registerForm_3[playerid][3] || playertextid == PTD_registerForm_3[playerid][1])
  759.             {
  760.                 new button, style = pinfo[playerid][pstylelife];
  761.                 if(playertextid == PTD_registerForm_3[playerid][3]) button = 1;
  762.                 else if(playertextid == PTD_registerForm_3[playerid][1]) button = 2;
  763.                 style =(button == 1) ? (style-1) : (style+1);
  764.                 if(style == 0) style = 3;
  765.                 else if(style == 4) style = 1;
  766.                 PlayerTextDrawSetString(playerid, PTD_registerForm_3[playerid][4], data_selectStyleLife[style-1][title]);
  767.                 SetPlayerCameraPos(playerid, data_selectStyleLife[style-1][cam11], data_selectStyleLife[style-1][cam12], data_selectStyleLife[style-1][cam13]);
  768.                 SetPlayerCameraLookAt(playerid, data_selectStyleLife[style-1][cam21], data_selectStyleLife[style-1][cam22], data_selectStyleLife[style-1][cam23]);
  769.                 pinfo[playerid][pstylelife] = style;
  770.             }
  771.         }
  772.         else if(GPVI(playerid, "registration_step") == 4)
  773.         {
  774.             if(!(_:playertextid ^ 0xFFFF)) return SelectTextDraw(playerid, 0xEA7500ff);
  775.             else if(playertextid == PTD_registerForm_4[playerid][6])
  776.             {
  777.                 for(new i = 0; i < 8; i++) PlayerTextDrawDestroy(playerid, PTD_registerForm_4[playerid][i]);
  778.                 kick(playerid);
  779.                 return 1;
  780.             }
  781.             else if(playertextid == PTD_registerForm_4[playerid][4])
  782.             {
  783.                 for(new i = 0; i < 8; i++) PlayerTextDrawDestroy(playerid, PTD_registerForm_4[playerid][i]);
  784.                 DPVAR(playerid, "registration_skinval");
  785.                 InterpolateCameraPos(playerid, 1403.804443, -791.208496, 100.563995, 1403.656616, -802.468444, 94.643310, 5000);
  786.                 InterpolateCameraLookAt(playerid, 1403.729858, -795.505554, 98.008613, 1403.678833, -807.376586, 93.689659, 5000);
  787.                 SPVI(playerid, "registration_miniature", gettime()+5);
  788.                 SPVI(playerid, "registration_miniaturestep", 1);
  789.                 SPVI(playerid, "registration_step", 5);
  790.                 CancelSelectTextDraw(playerid);
  791.                 PlayAudioStreamForPlayer(playerid, "http://western-state.ru/intro.mp3");
  792.                 for(new c = 0; c < 21; c++) scm(playerid, " ");
  793.                 gen_random_uniq(player_rand_miniatures[playerid], 7);
  794.                 return 1;
  795.             }
  796.             else if((playertextid == PTD_registerForm_4[playerid][1]) || (playertextid == PTD_registerForm_4[playerid][2])) // left
  797.             {
  798.                 new skinval, button;
  799.                 if(playertextid == PTD_registerForm_4[playerid][1]) button = 2, skinval = GPVI(playerid, "registration_skinval")+1;
  800.                 else if(playertextid == PTD_registerForm_4[playerid][2]) button = 1, skinval = GPVI(playerid, "registration_skinval")-1;
  801.                 new idskin = nationalitySkin[pinfo[playerid][pgender]-1][pinfo[playerid][pnational]-1][skinval];
  802.                 if((button == 1) && skinval == -1) return 1;
  803.                 else if((button == 2) && ((idskin == -1) || (skinval == 7))) return 1;
  804.                 SPVI(playerid, "registration_skinval", skinval);
  805.                 pinfo[playerid][pskin] = nationalitySkin[pinfo[playerid][pgender]-1][pinfo[playerid][pnational]-1][skinval];
  806.                 reshowPTDRegister_skinPrev(playerid);
  807.                 return 1;
  808.             }
  809.         }
  810.     }
  811.     return 1;
  812. }
  813.  
  814. public OnPlayerEnterDynamicArea(playerid, areaid)
  815. {
  816.     return 1;
  817. }
  818.  
  819. public OnPlayerLeaveDynamicArea(playerid, areaid)
  820. {
  821.     return 1;
  822. }
  823.  
  824. // ============================================================================= STOCK
  825. #include <PTD\stock_PTD_register.login>
  826.  
  827. stock scmall(string[])
  828. {
  829.     foreach(new i : Player) if(pinfo[i][plogin] && GPVI(i, "registration_step") < 1) scm(i, string);
  830.     return 1;
  831. }
  832.  
  833. stock kick(playerid)
  834. {
  835.     SPVI(playerid, "kicktime", gettime()+3);
  836.     TogglePlayerControllable(playerid, 0);
  837.     pinfo[playerid][plogin] = false;
  838.     return 1;
  839. }
  840.  
  841. stock gen_random_uniq(array[], array_size)
  842. {
  843.     new temp_array[17] = {0, 1, ...};
  844.     for(new i, temp, index[2]; i != 100; i++)
  845.     {
  846.         index[0] = random(sizeof(temp_array));
  847.         index[1] = random(sizeof(temp_array));
  848.         temp = temp_array[index[0]];
  849.         temp_array[index[0]] = temp_array[index[1]];
  850.         temp_array[index[1]] = temp;
  851.     }
  852.     for(new i; i != array_size; i++) array[i] = temp_array[i];
  853.     return 1;
  854. }
  855.  
  856.  
  857. stock setPlayerWorld(playerid, world)
  858. {
  859.     SetPlayerVirtualWorld(playerid, world);
  860.     pinfo[playerid][psaveworld] = world;
  861.     return 1;
  862. }
  863.  
  864. stock setPlayerInt(playerid, int)
  865. {
  866.     SetPlayerInterior(playerid, int);
  867.     pinfo[playerid][psaveint] = int;
  868.     return 1;
  869. }
  870.  
  871. stock setPlayerSkin(playerid, skin)
  872. {
  873.     SetPlayerSkin(playerid, skin);
  874.     pinfo[playerid][pskin] = skin;
  875.     return 1;
  876. }
  877.  
  878. stock setPlayerPos(playerid, Float: pos0, Float: pos1, Float: pos2, Float: pos3)
  879. {
  880.     SetPlayerPos(playerid, pos0, pos1, pos2);
  881.     SetPlayerFacingAngle(playerid, pos3);
  882.     TogglePlayerControllable(playerid, 0);
  883.     SPVI(playerid, "setPlayerPos_timer", gettime()+1);
  884.     return 1;
  885. }
  886.  
  887. stock getPlayerInt(playerid) return GetPlayerInterior(playerid);
  888. stock getPlayerWorld(playerid) return GetPlayerVirtualWorld(playerid);
  889. stock getPlayerSkin(playerid) return GetPlayerSkin(playerid);
  890. stock getPlayerPos(playerid, Float: pos[3]) return GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  891.  
  892. // MySQL FUNCTIONs
  893. forward ormsql_playerCheckedIsBase(playerid);
  894. public ormsql_playerCheckedIsBase(playerid)
  895. {
  896.     PlayAudioStreamForPlayer(playerid, "http://western-state.ru/registration.mp3");
  897.     if(orm_errno(pinfo[playerid][pormid]) == ERROR_OK) createPTDLogin(playerid), SPVI(playerid, "login_step", 1);
  898.     else if(orm_errno(pinfo[playerid][pormid]) == ERROR_NO_DATA) createPTDRegister_1(playerid), SPVI(playerid, "registration_step", 1);
  899.     orm_setkey(pinfo[playerid][pormid], "puid");
  900.     return 1;
  901. }
  902.  
  903. forward ormsql_playerRegister(playerid);
  904. public ormsql_playerRegister(playerid)
  905. {
  906.     for(new i = 0; i < 2; i++) PlayerTextDrawDestroy(playerid, PTD_registerForm_6[playerid][i]);
  907.     TogglePlayerControllable(playerid, 1);
  908.     setPlayerWorld(playerid, 0);
  909.     SetCameraBehindPlayer(playerid);
  910.     StopAudioStreamForPlayer(playerid);
  911.     new string[24+80];
  912.    
  913.     format(string, sizeof string, "{"colorServer"}%s, âû óñïåøíî çàðåãèñòðèðîâàëèñü íà ñåðâåðå Western State.", pinfo[playerid][pname]);
  914.     scm(playerid, string);
  915.     scm(playerid, "{"colorGreen"}Óäà÷íîé èãðû!");
  916.     pinfo[playerid][plogin] = true;
  917.     DPVAR(playerid, "registration_step");
  918.     DPVAR(playerid, "registration_miniature"), DPVAR(playerid, "registration_miniaturestep");
  919.     return 1;
  920. }
  921.  
  922. // ============================================================================= TIMER
  923. forward timer();
  924. public timer()
  925. {
  926.     foreach(new playerid : Player)
  927.     {
  928.         if((GPVI(playerid, "kicktime") > 0) && (gettime() > GPVI(playerid, "kicktime"))) Kick(playerid);
  929.         if(GPVI(playerid, "setPlayerPos_timer")) if(gettime() > GPVI(playerid, "setPlayerPos_timer")) DPVAR(playerid, "setPlayerPos_timer"), TogglePlayerControllable(playerid, 1);
  930.  
  931.         if(GPVI(playerid, "registration_loading") > 1)
  932.         {
  933.             for(new c = 0; c < 19; c++) scm(playerid, " ");
  934.             scm(playerid, "{"colorServer"}Äîáðî ïîæàëîâàòü íà Role Play ñåðâåð, Western State.");
  935.             scm(playerid, " "), scm(playerid, " ");
  936.             new string[50];
  937.             format(string, sizeof string, "{"colorGrey"}Çàãðóçêà èãðîâîãî ìîäà: îñòàëîñü %i (ñåê).", GPVI(playerid, "registration_loading")-1);
  938.             scm(playerid, string);
  939.             SPVI(playerid, "registration_loading", GPVI(playerid, "registration_loading")-1);
  940.         }
  941.         else if(GPVI(playerid, "registration_loading") == 1)
  942.         {
  943.             DPVAR(playerid, "registration_loading");
  944.             new ORM: ORMID = pinfo[playerid][pormid] = orm_create("players", CH);
  945.             orm_addvar_int(ORMID, pinfo[playerid][puid], "puid");
  946.             orm_addvar_string(ORMID, pinfo[playerid][pname], 24, "pname");
  947.             orm_addvar_string(ORMID, pinfo[playerid][pemail], 128, "pemail");
  948.             orm_addvar_string(ORMID, pinfo[playerid][ppass], 12, "ppass");
  949.             orm_addvar_int(ORMID, pinfo[playerid][pcash], "pcash");
  950.             orm_addvar_int(ORMID, pinfo[playerid][pskin], "pskin");
  951.             orm_addvar_int(ORMID, pinfo[playerid][plastskin], "plastskin");
  952.             orm_addvar_int(ORMID, pinfo[playerid][padmin], "padmin");
  953.             orm_addvar_int(ORMID, pinfo[playerid][pnational], "pnational");
  954.             orm_addvar_int(ORMID, pinfo[playerid][pgender], "pgender");
  955.             orm_addvar_int(ORMID, pinfo[playerid][page], "page");
  956.             orm_addvar_int(ORMID, pinfo[playerid][pstylelife], "pstylelife");
  957.             orm_addvar_int(ORMID, pinfo[playerid][psaveworld], "psaveworld");
  958.             orm_addvar_int(ORMID, pinfo[playerid][psaveint], "psaveint");
  959.             orm_addvar_string(ORMID, pinfo[playerid][psavepos], 55, "psavepos");
  960.  
  961.             orm_setkey(ORMID, "pname");
  962.             orm_select(ORMID, "ormsql_playerCheckedIsBase", "i", playerid);
  963.         }
  964.        
  965.         if(GPVI(playerid, "registration_step") == 5)
  966.         {
  967.             if(gettime() >= GPVI(playerid, "registration_miniature"))
  968.             {
  969.                 if(GPVI(playerid, "registration_miniaturestep") < 8)
  970.                 {
  971.                     if(GPVI(playerid, "registration_miniaturestep") == 6) createPTDRegister_5(playerid);
  972.                     new val = player_rand_miniatures[playerid][GPVI(playerid, "registration_miniaturestep")-1];
  973.                     InterpolateCameraPos(playerid, registration_miniatures[val][0][0], registration_miniatures[val][0][1], registration_miniatures[val][0][2], registration_miniatures[val][0][3], registration_miniatures[val][0][4], registration_miniatures[val][0][5], 5000);
  974.                     InterpolateCameraLookAt(playerid, registration_miniatures[val][1][0], registration_miniatures[val][1][1], registration_miniatures[val][1][2], registration_miniatures[val][1][3], registration_miniatures[val][1][4], registration_miniatures[val][1][5], 5000);
  975.                 }
  976.                 else if(GPVI(playerid, "registration_miniaturestep") == 8)
  977.                 {
  978.                     TogglePlayerSpectating(playerid, 0);
  979.                     SpawnPlayer(playerid);
  980.                 }
  981.                 else if(GPVI(playerid, "registration_miniaturestep") == 9)
  982.                 {
  983.                     orm_insert(pinfo[playerid][pormid], "ormsql_playerRegister", "d", playerid);
  984.                     return 1;
  985.                 }
  986.                 SPVI(playerid, "registration_miniaturestep", GPVI(playerid, "registration_miniaturestep")+1);
  987.                 SPVI(playerid, "registration_miniature", gettime()+5);
  988.             }
  989.         }
  990.         if(GPVI(playerid, "pass_obt_sec") > 1)
  991.         {
  992.             SPVI(playerid, "pass_obt_sec", GPVI(playerid, "pass_obt_sec")-1);
  993.             new str[20];
  994.             format(str, 20, "{"colorRed"}(%i) sec", GPVI(playerid, "pass_obt_sec")-1);
  995.             for(new m = 0; m < 21; m++) scm(playerid, " ");
  996.             scm(playerid, str);
  997.         }
  998.         else if(GPVI(playerid, "pass_obt_sec") == 1)
  999.         {
  1000.             scm(playerid, "{"colorRed"}Password is not correct.");
  1001.             DPVAR(playerid, "pass_obt_sec");
  1002.             kick(playerid);
  1003.             return 1;
  1004.         }
  1005.     }
  1006.     return 1;
  1007. }
  1008.  
  1009.  
  1010. // ============================================================================= COMMAND (user)
  1011. COMMAND:ucmds(playerid, params[])
  1012. {
  1013.     scm(playerid, "{"colorYellow"}Êîìàíäû èãðîêà:");
  1014.     scm(playerid, "{"colorGrey"}/mm");
  1015.     return 1;
  1016. }
  1017. COMMAND:mm(playerid, params[])
  1018. {
  1019.     scm(playerid, "{"colorGrey"}Êîìàíäà mm íàõîäèòñÿ â ðàçðàáîòêå.");
  1020.     return 1;
  1021. }
  1022. // ============================================================================= COMMAND (admin)
  1023. COMMAND:acmds(playerid, params[])
  1024. {
  1025.     scm(playerid, "{"colorYellow"}Êîìàíäû àäìèíèñòðàòîðà:");
  1026.     scm(playerid, "{"colorGrey"}/a text");
  1027.     scm(playerid, "{"colorGrey"}/getinfo nickname");
  1028.     scm(playerid, "{"colorGrey"}/kick playerid reason");
  1029.     scm(playerid, "{"colorGrey"}/mute playerid min reason");
  1030.     scm(playerid, "{"colorGrey"}/unmute playerid");
  1031.     scm(playerid, "{"colorGrey"}/ban playerid days reason");
  1032.     scm(playerid, "{"colorGrey"}/unban nickname");
  1033.     scm(playerid, "{"colorGrey"}/offban nickname days reason");
  1034.     scm(playerid, "{"colorGrey"}/goto playerid");
  1035.     scm(playerid, "{"colorGrey"}/gethere playerid");
  1036.     return 1;
  1037. }
  1038. COMMAND:a(playerid, params[])
  1039. {
  1040.     if(isAdmin(1)) return 1;
  1041.     scm(playerid, "{"colorGrey"}Êîìàíäà a íàõîäèòñÿ â ðàçðàáîòêå.");
  1042.     return 1;
  1043. }
  1044. COMMAND:getinfo(playerid, params[])
  1045. {
  1046.     if(isAdmin(1)) return 1;
  1047.     scm(playerid, "{"colorGrey"}Êîìàíäà getinfo íàõîäèòñÿ â ðàçðàáîòêå.");
  1048.     return 1;
  1049. }
  1050. COMMAND:kick(playerid, params[])
  1051. {
  1052.     if(isAdmin(1)) return 1;
  1053.     scm(playerid, "{"colorGrey"}Êîìàíäà kick íàõîäèòñÿ â ðàçðàáîòêå.");
  1054.     return 1;
  1055. }
  1056. COMMAND:mute(playerid, params[])
  1057. {
  1058.     if(isAdmin(1)) return 1;
  1059.     scm(playerid, "{"colorGrey"}Êîìàíäà mute íàõîäèòñÿ â ðàçðàáîòêå.");
  1060.     return 1;
  1061. }
  1062. COMMAND:unmute(playerid, params[])
  1063. {
  1064.     if(isAdmin(1)) return 1;
  1065.     scm(playerid, "{"colorGrey"}Êîìàíäà unmute íàõîäèòñÿ â ðàçðàáîòêå.");
  1066.     return 1;
  1067. }
  1068. COMMAND:ban(playerid, params[])
  1069. {
  1070.     if(isAdmin(1)) return 1;
  1071.     scm(playerid, "{"colorGrey"}Êîìàíäà ban íàõîäèòñÿ â ðàçðàáîòêå.");
  1072.     return 1;
  1073. }
  1074. COMMAND:unban(playerid, params[])
  1075. {
  1076.     if(isAdmin(1)) return 1;
  1077.     scm(playerid, "{"colorGrey"}Êîìàíäà unban íàõîäèòñÿ â ðàçðàáîòêå.");
  1078.     return 1;
  1079. }
  1080. COMMAND:offban(playerid, params[])
  1081. {
  1082.     if(isAdmin(1)) return 1;
  1083.     scm(playerid, "{"colorGrey"}Êîìàíäà offban íàõîäèòñÿ â ðàçðàáîòêå.");
  1084.     return 1;
  1085. }
  1086. COMMAND:goto(playerid, params[])
  1087. {
  1088.     if(isAdmin(1)) return 1;
  1089.     scm(playerid, "{"colorGrey"}Êîìàíäà goto íàõîäèòñÿ â ðàçðàáîòêå.");
  1090.     return 1;
  1091. }
  1092. COMMAND:gethere(playerid, params[])
  1093. {
  1094.     if(isAdmin(1)) return 1;
  1095.     scm(playerid, "{"colorGrey"}Êîìàíäà gethere íàõîäèòñÿ â ðàçðàáîòêå.");
  1096.     return 1;
  1097. }
  1098.  
  1099. // ============================================================================= COMMAND (test)
  1100. COMMAND:tcmds(playerid, params[])
  1101. {
  1102.     scm(playerid, "{"colorYellow"}Êîìàíäû òåñòåðà:");
  1103.     scm(playerid, "{"colorGrey"}/adm");
  1104.     scm(playerid, "{"colorGrey"}/testinfo");
  1105.     scm(playerid, "{"colorGrey"}/pos x,y,z");
  1106.     scm(playerid, "{"colorGrey"}/gun weaponid ammo");
  1107.     scm(playerid, "{"colorGrey"}/car modelid");
  1108.     scm(playerid, "{"colorGrey"}/gotospawn 1-3");
  1109.     return 1;
  1110. }
  1111. COMMAND:adm(playerid, params[])
  1112. {
  1113.     pinfo[playerid][padmin] = 1;
  1114.     scm(playerid, "{"colorGreen"}~~~~ Adm 1");
  1115.     return 1;
  1116. }
  1117. COMMAND:testinfo(playerid, params[])
  1118. {
  1119.     new str[100];
  1120.     format(str, sizeof str, "plogin - %d", pinfo[playerid][plogin]), scm(playerid, str);
  1121.     format(str, sizeof str, "pcurrentworld - %d", getPlayerWorld(playerid)), scm(playerid, str);
  1122.     format(str, sizeof str, "pcurrentint - %d", getPlayerInt(playerid)), scm(playerid, str);
  1123.     scm(playerid, " ");
  1124.     format(str, sizeof str, "puid - %d", pinfo[playerid][puid]), scm(playerid, str);
  1125.     format(str, sizeof str, "pname - %s", pinfo[playerid][pname]), scm(playerid, str);
  1126.     format(str, sizeof str, "pemail - %s", pinfo[playerid][pemail]), scm(playerid, str);
  1127.     format(str, sizeof str, "ppass - %s", pinfo[playerid][ppass]), scm(playerid, str);
  1128.     format(str, sizeof str, "pcash - %d", pinfo[playerid][pcash]), scm(playerid, str);
  1129.     format(str, sizeof str, "pskin - %d", pinfo[playerid][pskin]), scm(playerid, str);
  1130.     format(str, sizeof str, "plastskin - %d", pinfo[playerid][plastskin]), scm(playerid, str);
  1131.     format(str, sizeof str, "padmin - %d", pinfo[playerid][padmin]), scm(playerid, str);
  1132.     format(str, sizeof str, "pgender - %d", pinfo[playerid][pgender]), scm(playerid, str);
  1133.     format(str, sizeof str, "pnational - %d", pinfo[playerid][pnational]), scm(playerid, str);
  1134.     format(str, sizeof str, "page - %d", pinfo[playerid][page]), scm(playerid, str);
  1135.    
  1136.     return 1;
  1137. }
  1138.    
  1139. COMMAND:pos(playerid, params[])
  1140. {
  1141.     new Float: pos[3];
  1142.     if(sscanf(params, "p<,>fff", pos[0], pos[1], pos[2])) return scm(playerid, "/pos x,y,z");
  1143.     SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  1144.     return 1;
  1145. }
  1146.  
  1147. COMMAND:gotospawn(playerid, params[])
  1148. {
  1149.     new style;
  1150.     if(sscanf(params, "i", style)) return scm(playerid, "/gotospawn [spawn 1-3] -(1. Gangster | 2. Urban | 3. Village)");
  1151.     if(style < 0 || style > 12) return 1;
  1152.     return 1;
  1153. }
  1154.  
  1155. COMMAND:car(playerid, params[])
  1156. {
  1157.     if(sscanf(params, "i", params[0])) return 1;
  1158.     if(params[0] < 400 || params[0] > 611) return 1;
  1159.     new Float: ppos[4];
  1160.     GetPlayerPos(playerid, ppos[0], ppos[1], ppos[2]), GetPlayerFacingAngle(playerid, ppos[3]);
  1161.     new carid = CreateVehicle(params[0], ppos[0], ppos[1], ppos[2], ppos[3], -1, -1, 5000);
  1162.     PutPlayerInVehicle(playerid, carid, 0);
  1163.     return 1;
  1164. }
  1165.  
  1166. COMMAND:gun(playerid, params[])
  1167. {
  1168.     if(sscanf(params, "ii", params[0], params[1])) return 1;
  1169.     if(params[0] < 1 || params[0] > 46) return 1;
  1170.     if(params[1] < 1 || params[1] > 100) return 1;
  1171.     GivePlayerWeapon(playerid, params[0], params[1]);
  1172.     return 1;
  1173. }
  1174.  
  1175. COMMAND:int(playerid, params[])
  1176. {
  1177.     if(sscanf(params, "i", params[0])) return 1;
  1178.     SetPlayerInterior(playerid, params[0]);
  1179.     return 1;
  1180. }
  1181.  
  1182. COMMAND:vworld(playerid, params[])
  1183. {
  1184.     if(sscanf(params, "i", params[0])) return 1;
  1185.     SetPlayerVirtualWorld(playerid, params[0]);
  1186.     return 1;
  1187. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement