Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 9.55 KB | None | 0 0
  1. > DIALOGS
  2.  
  3. #define     DIALOG_REGISTER     (0)
  4. #define     DIALOG_LOGIN        (1)
  5. #define     DIALOG_SEX          (2)
  6. #define     DIALOG_BCITY        (3)
  7. #define     DIALOG_BDAY         (4)
  8. #define     DIALOG_BMONTH       (5)
  9. #define     DIALOG_BYEAR        (6)
  10. #define     DIALOG_TUTORIAL     (7)
  11. #define     DIALOG_CHECK1       (8)
  12. #define     DIALOG_CHECK2       (9)
  13. #define     DIALOG_CHECK3       (10)
  14. #define     DIALOG_SPAWN        (11)
  15.  
  16.  
  17.  
  18.  
  19. > OnPlayerConnect
  20.  
  21.  
  22.  
  23. public OnPlayerConnect(playerid)
  24. {
  25.     ResetPlayer(playerid);
  26.     SetPlayerCamera(playerid);
  27.  
  28.     new pCheck[248];
  29.     mysql_format(sqlDB, pCheck, sizeof(pCheck), "SELECT * FROM accounts WHERE acc_name = '%e'", ReturnName(playerid));
  30.     mysql_tquery(sqlDB, pCheck, "LoggingIn", "i", playerid);
  31.  
  32.     return 1;
  33. }
  34.  
  35.  
  36.  
  37.  
  38. > OnPlayerRequestClass * I suspect it's what spawns me
  39.  
  40.  
  41.  
  42.  
  43. public OnPlayerRequestClass(playerid, classid)
  44. {
  45.     if(PlayerInfo[playerid][LoggedIn] == false)
  46.     {
  47.         SetSpawnInfo(playerid, 0, 0, 563.3157, 3315.2559, 0, 269.15, 0, 0, 0, 0, 0, 0);
  48.         TogglePlayerSpectating(playerid, true);
  49.         TogglePlayerSpectating(playerid, false);
  50.         SetPlayerCamera(playerid);
  51.         return 1;
  52.     }
  53.     SetSpawnInfo(playerid, 0, 1, 2098.5088,1159.1156,11.6484, 65.2418, 0, 0, 0, 0, 0, 0 ); // this line gets called somehow?
  54.     SpawnPlayer(playerid);
  55.    return 0;
  56. }
  57.  
  58.  
  59.  
  60.  
  61. > "LoggingIn" Function which is called from OnPlayerConnect:
  62.  
  63.  
  64.  
  65. function:LoggingIn(playerid) // Gets called when a player connects basically instead of OnPlayerConnect
  66. {
  67.     new rows, fields;
  68.     cache_get_data(rows, fields, sqlDB);
  69.     if(!rows)
  70.     {
  71.         ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""COL_ASOCIETY"aSociety Gaming Roleplay", pDialog, "Let's go!", "Quit");
  72.     }
  73.     else
  74.     {
  75.         ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, ""COL_ASOCIETY"aSociety Gaming Roleplay", pLoginDialog, "Login", "Quit");
  76.     }  
  77.     return 1;
  78. }
  79.  
  80.  
  81.  
  82.  
  83.  
  84. > Registration DIALOG
  85.  
  86.  
  87.  
  88.  
  89. case DIALOG_REGISTER:
  90.         {
  91.             if(!response)
  92.                 return Kick(playerid);
  93.  
  94.             if(strlen(inputtext) > 20 || strlen(inputtext) < 4)
  95.                 return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""COL_ASOCIETY"aSociety Gaming Roleplay", ""COL_WHITE"> The password you select must contain at least "COL_ERROR"4 characters"COL_WHITE", and be shorter than "COL_SERVER"20 characters"COL_WHITE".", "Register!", "Quit");
  96.  
  97.             new regInfo[256];
  98.             mysql_format(sqlDB, regInfo, sizeof(regInfo), "INSERT INTO accounts (acc_name, acc_password, register_ip, register_date) VALUES ('%e', sha1('%e'), '%e', '%e')", ReturnName(playerid), inputtext, ReturnIP(playerid), ReturnDate());
  99.             mysql_tquery(sqlDB, regInfo, "OnPlayerRegister", "i", playerid);
  100.  
  101.         }
  102.  
  103.  
  104. OnPlayerRegister Function which is called from the dialog:
  105.  
  106. function:OnPlayerRegister(playerid)
  107. {
  108.     PlayerInfo[playerid][LoggedIn] = true;
  109.     PlayerInfo[playerid][pDBID] = cache_insert_id();
  110.     format(PlayerInfo[playerid][pName], 32, "%s", ReturnName(playerid));
  111.     CLS(playerid);
  112.     SCM(playerid, COLOR_SERVER, "** [Server] > "COL_WHITE"Awsome! Now after you have chosen your "COL_SERVER"password"COL_WHITE" we have some minor tweaks to do. "COL_SERVER"**");
  113.     SCM(playerid, COLOR_SERVER, "** [Server] > "COL_WHITE"Don't worry, it won't take too long. "COL_SERVER"**");
  114.     ShowPlayerDialog(playerid, DIALOG_SEX, DIALOG_STYLE_LIST, ""COL_REGISTER"[Account-Setup] > Gender Definition", ""COL_WHITE"I am a male!\nI am a female!", "Select", "Quit");
  115.     return 1;
  116. }
  117.  
  118.  
  119. This prompts you to choose your CHARACTER SETUP, and then to the TUTORIAL and then this is executed on the last DIALOG of the tutorial:
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126. > Spawning the player
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133. case DIALOG_SPAWN:
  134.         {
  135.             if(!response)
  136.                 return Kick(playerid);
  137.  
  138.             SetSpawnInfo(playerid, 0, 230, 937.7089,-1717.3564,13.5469,95.4095, 0, 0, 0, 0, 0, 0);
  139.  
  140.             SetPlayerPos(playerid, 937.7089,-1717.3564,13.5469);
  141.            
  142.  
  143.             TogglePlayerSpectating(playerid, false);
  144.             TogglePlayerControllable(playerid, true);
  145.             SetPlayerFacingAngle(playerid, 90);
  146.             SetCameraBehindPlayer(playerid);
  147.  
  148.            
  149.            
  150.            
  151.             GivePlayerMoney(playerid, 7500);
  152.             PlayerInfo[playerid][pCash] = 0;
  153.             PlayerInfo[playerid][pCash] += 7500;
  154.             new pCashSQL[256];
  155.             mysql_format(sqlDB, pCashSQL, sizeof(pCashSQL), "UPDATE accounts SET player_cash = '%i' WHERE DBID = '%i'", PlayerInfo[playerid][pCash], PlayerInfo[playerid][pDBID]);
  156.             mysql_tquery(sqlDB, pCashSQL);
  157.  
  158.             SetPlayerSkin(playerid, 230);
  159.             PlayerInfo[playerid][pSkin] = 230;
  160.             new pSkinSQL[256];
  161.             mysql_format(sqlDB, pSkinSQL, sizeof(pSkinSQL), "UPDATE accounts SET player_skin = '%i' WHERE DBID = '%i'", PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pDBID]);
  162.             mysql_tquery(sqlDB, pSkinSQL);
  163.  
  164.             SetPlayerHealth(playerid, 100);
  165.             PlayerInfo[playerid][pHealth] = 100;
  166.             new pHealthSQL[256];
  167.             mysql_format(sqlDB, pHealthSQL, sizeof(pHealthSQL), "UPDATE accounts SET player_health = '%i' WHERE DBID = '%i'", PlayerInfo[playerid][pHealth], PlayerInfo[playerid][pDBID]);
  168.             mysql_tquery(sqlDB, pHealthSQL);
  169.  
  170.             SetPlayerArmour(playerid, 50);
  171.             PlayerInfo[playerid][pArmour] = 50;
  172.             new pArmourSQL[256];
  173.             mysql_format(sqlDB, pArmourSQL, sizeof(pArmourSQL), "UPDATE accounts SET player_armour = '%i' WHERE DBID = '%i'", PlayerInfo[playerid][pArmour], PlayerInfo[playerid][pDBID]);
  174.             mysql_tquery(sqlDB, pArmourSQL);
  175.  
  176.             SetPlayerVirtualWorld(playerid, 0);
  177.             PlayerInfo[playerid][pVW] = 0;
  178.             new pVWSQL[256];
  179.             mysql_format(sqlDB, pVWSQL, sizeof(pVWSQL), "UPDATE accounts SET player_vw = '%i' WHERE DBID = '%i'", PlayerInfo[playerid][pVW], PlayerInfo[playerid][pDBID]);
  180.             mysql_tquery(sqlDB, pVWSQL);
  181.  
  182.  
  183.  
  184.             CLS(playerid);
  185.             SCMex(playerid, COLOR_ASOCIETY, "** [Server] > "COL_WHITE"Congratulations "COL_SERVER"%s"COL_WHITE"! You have successfully finished the tutorial! "COL_SERVER"**", ReturnName(playerid));
  186.             SCM(playerid, COLOR_ASOCIETY, "** [Server] > "COL_WHITE"You have been spawned with "COL_SERVER"7,500$"COL_WHITE" on-hand, and "COL_SERVER"2,500$"COL_WHITE" in your bank account. "COL_SERVER"**");
  187.             SCM(playerid, COLOR_YELLOW, "** [Note] > You have spawned with 50 armour because it's your first time spawning. **");
  188.  
  189.  
  190.         }
  191.  
  192.  
  193.  
  194.  
  195.  
  196. LOGIN PART >
  197.  
  198.  
  199.  
  200. case DIALOG_LOGIN:
  201.         {
  202.             if(!response)
  203.             {
  204.                 SCM(playerid, COLOR_SERVER, "** [Server] > You were kicked for aborting the login! **");
  205.                 KickEx(playerid);
  206.             }
  207.  
  208.             new playerCheck[256];
  209.             mysql_format(sqlDB, playerCheck, sizeof(playerCheck), "SELECT DBID FROM accounts WHERE acc_name = '%e' AND acc_password = sha1('%e') LIMIT 1", ReturnName(playerid), inputtext);
  210.            mysql_tquery(sqlDB, playerCheck, "LogPlayerIn", "i", playerid);
  211.            return 1;
  212.         }
  213.  
  214.  
  215.  
  216.  
  217.  
  218. Log Player In function which is called from the login >
  219.  
  220.  
  221.  
  222.  
  223. function:LogPlayerIn(playerid)
  224. {
  225.     if(!cache_num_rows())
  226.     {
  227.         playerLogin[playerid]++;
  228.         if(playerLogin[playerid] == 3)
  229.         {
  230.             SCM(playerid, COLOR_ERROR, "*** [Server] > You were kicked due to providing a wrong password 3 times. ***");
  231.             Kick(playerid);
  232.             return 1;
  233.         }
  234.  
  235.         new pLoginDialog[1024];
  236.         strcat(pLoginDialog, "\n", sizeof(pLoginDialog));
  237.         strcat(pLoginDialog, ""COL_ASOCIETY"> Login || "COL_ERROR"Wrong password provided!\n", sizeof(pLoginDialog));
  238.         strcat(pLoginDialog, "\n", sizeof(pLoginDialog));
  239.         strcat(pLoginDialog, ""COL_WHITE"> Welcome back to our server!\n", sizeof(pLoginDialog));
  240.         strcat(pLoginDialog, ""COL_WHITE"> We see your account is already "COL_SERVER"registered on our database"COL_WHITE", please provide the password you used on your "COL_SERVER"registration.\n", sizeof(pLoginDialog));
  241.         strcat(pLoginDialog, ""COL_WHITE"> Providing a wrong password several times will get you kicked and the attempt will be reported to the admins.\n", sizeof(pLoginDialog));
  242.         strcat(pLoginDialog, "\n", sizeof(pLoginDialog));
  243.         strcat(pLoginDialog, ""COL_YELLOW"> [Note]: "COL_WHITE"Impersonating someone will result in a "COL_ERROR"permanent range ban"COL_WHITE", please do not try "COL_TUTORIAL"exploiting"COL_WHITE" accounts!\n", sizeof(pLoginDialog));
  244.         strcat(pLoginDialog, "\n", sizeof(pLoginDialog));
  245.         strcat(pLoginDialog, ""COL_YELLOW"* proTip: If you forgot your password please post an appeal on our forums: "COL_TUTORIAL"https://forum.asocietygaming.com\n", sizeof(pLoginDialog));
  246.        
  247.         ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, ""COL_ASOCIETY"aSociety Gaming Roleplay", pLoginDialog, "Login", "Quit");
  248.         return 1;
  249.     }
  250.  
  251.     new rows, fields;
  252.    cache_get_data(rows, fields, sqlDB);
  253.  
  254.    PlayerInfo[playerid][pDBID] = cache_get_field_content_int(0, "DBID", sqlDB);
  255.  
  256.    format(PlayerInfo[playerid][pName], 32, "%s", ReturnName(playerid));
  257.    PlayerInfo[playerid][LoggedIn] = true;
  258.    
  259.  
  260.    SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], 937.7089,-1717.3564,13.5469,95.4095, 0, 0, 0, 0, 0, 0);
  261.  
  262.     SetPlayerPos(playerid, 937.7089,-1717.3564,13.5469);
  263.            
  264.  
  265.     TogglePlayerSpectating(playerid, false);
  266.     TogglePlayerControllable(playerid, true);
  267.     SetPlayerFacingAngle(playerid, 90);
  268.     SetCameraBehindPlayer(playerid);
  269.  
  270.  
  271.     GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
  272.     SetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
  273.     SetPlayerArmour(playerid, PlayerInfo[playerid][pArmour]);
  274.  
  275.     return 1;
  276. }
  277.  
  278.  
  279.  
  280.  
  281.  
  282. Basically what it does it checks the password for wrong attempts 3 times, if it doesn't match it returns a kick, if it does it returns all the rest of the code which is shown below, and everything works fine, but when I give player money etc... it gives me 0 values.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement