Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <a_mysql>
- #include <colors>
- #include <sscanf2>
- #include <CameraMover>
- #include <zcmd>
- #include <streamer>
- #include <intro>
- #define function%0(%1) forward%0(%1); public%0(%1)
- enum pInfo {
- pSQLID,
- pName[MAX_PLAYER_NAME],
- pPassword[32],
- pEmail[32],
- pSkin,
- pMember,
- pLeader,
- pAdmin,
- pHelper,
- pTutorial
- }
- enum {
- // Register
- DIALOG_REGISTER,
- DIALOG_EMAIL,
- // Login
- DIALOG_LOGIN,
- // Mesaje
- DIALOG_TUTORIAL_COLECTARE_BAGAJ
- }
- new PlayerInfo[MAX_PLAYERS][pInfo];
- new SQL = -1, gQuery[256], gString[256];
- new incercariParola[MAX_PLAYERS];
- new bagaj, iesiretutorial;
- main() { print("Gamemode-ul e in curs de procesare..."); }
- public OnGameModeInit()
- {
- SQL = mysql_connect("localhost", "root", "zoldix_db", "");
- SendRconCommand("hostname Zoldix RPG | BETA");
- SetGameModeText("Zoldix RPG v1.0");
- CreateGlobalTextDraws();
- CreateGlobalObjects();
- bagaj = CreatePickup(1210, 1, 266.9013,96.4856,1033.3784, -1); //Virtual World (-1) is all worlds
- Create3DTextLabel("Te rugam sa iei valiza pentru a continua", 0x008080FF, 266.9013, 96.4856, 1033.3784, 40.0, 0, 0);
- iesiretutorial = CreatePickup(1239, 1, 270.3147,147.4576,1033.3920, -1); //Virtual World (-1) is all worlds
- Create3DTextLabel("Te rugam sa iei valiza pentru a continua", 0x008080FF, 270.3147,147.4576,1033.3920, 40.0, 0, 0);
- }
- public OnGameModeExit()
- {
- DestroyGlobalTextDraws();
- DestroyGlobalObjects();
- DestroyActors();
- ResetGlobalVariables();
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- if(PlayerInfo[playerid][pTutorial] == 0)
- {
- ClearPlayerChat(playerid, 32);
- TogglePlayerSpectating(playerid, 1);
- SetPlayerInterior(playerid, 12);
- SetPlayerCameraPos(playerid, 1093.000000, -2036.000000, 90.000000);
- SetPlayerCameraLookAt(playerid, 0.825859, 0.557950, -0.081537);
- ApplyActorAnimation(first_actor, "INT_SHOP", "shop_loop", 4.1, 1, 1, 1, 0, 0);
- return 1;
- }
- return 1;
- }
- public OnPlayerConnect(playerid) {
- incercariParola[playerid] = 0;
- gQuery[0] = EOS;
- mysql_format(SQL, gQuery, sizeof(gQuery), "SELECT * FROM `users` WHERE `Name`='%s' LIMIT 1",GetName(playerid));
- mysql_tquery(SQL, gQuery, "checkAccount", "i", playerid);
- if(PlayerInfo[playerid][pTutorial] == 0) CreatePlayerTextDraws(playerid);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- if(PlayerInfo[playerid][pTutorial] == 0)
- {
- SetPlayerInterior(playerid, 0);
- SetPlayerPos(playerid, 273.4211, 96.4937, 1033.3784);
- SetPlayerSkin(playerid, 26);
- SetPlayerVirtualWorld(playerid, 0);
- SetPlayerFacingAngle(playerid, 360.0);
- SetCameraBehindPlayer(playerid);
- StopAudioStreamForPlayer(playerid);
- }
- if(PlayerInfo[playerid][pTutorial] == 1)
- {
- SetPlayerInterior(playerid, 0);
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerSkin(playerid, 26);
- SetPlayerVirtualWorld(playerid, 0);
- SetPlayerFacingAngle(playerid, 360.0);
- SetCameraBehindPlayer(playerid);
- StopAudioStreamForPlayer(playerid);
- }
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- if(pickupid == bagaj)
- {
- if(PlayerInfo[playerid][pTutorial] == 0)
- {
- DestroyPickup(bagaj);
- ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Inregistrare", "Pentru a merge mai departe te rugam sa iti setezi o parola", "Select", "Cancel");
- }
- }
- if(pickupid == iesiretutorial)
- {
- if(PlayerInfo[playerid][pTutorial] == 0) SendClientMessage(playerid, COLOR_RED, "Nu poti iesi fara sa iei valiza!");
- if(PlayerInfo[playerid][pTutorial] == 1) SetPlayerPos(playerid, 1481.2548, -1741.8038, 14.5469);
- }
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(PlayerInfo[playerid][pTutorial] == 0)
- {
- KillPlayerTimers(playerid);
- DestroyPlayerTextDraws(playerid);
- ResetPlayerVariables(playerid);
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
- switch(dialogid) {
- case DIALOG_REGISTER: {
- if(strlen(inputtext) < 6)
- return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Parola ta e prea scurta (minim 6 caractere). Incearca din nou:", "Select", "Cancel");
- if(strlen(inputtext) > 32)
- return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Parola ta e prea lunga (maxim 32 caractere). Incearca din nou:", "Select", "Cancel");
- gQuery[0] = EOS;
- mysql_format(SQL, gQuery, sizeof(gQuery), "INSERT INTO `users` (`Name`, `Password`, `Tutorial`) VALUES ('%s', '%s', '1')", GetName(playerid), inputtext);
- mysql_tquery(SQL, gQuery, "insertAccount", "i", playerid);
- format(PlayerInfo[playerid][pPassword], 32 , inputtext);
- ShowPlayerDialog(playerid, DIALOG_EMAIL, DIALOG_STYLE_INPUT, "Email", "Seteaza-ti adresa ta de email", "Select", "Cancel");
- }
- case DIALOG_EMAIL: {
- if(!response)
- return Kick(playerid);
- if(strlen(inputtext) > 32)
- return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Email", "Email-ul tau e prea mare (maxim 32 caractere). Incearca din nou:", "Select", "Cancel");
- gQuery[0] = EOS;
- mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE `users` SET `Email`='%s', WHERE `ID`='%d'", GetName(playerid), inputtext);
- mysql_tquery(SQL, gQuery, "", "", playerid);
- PlayerInfo[playerid][pTutorial] = 1;
- format(PlayerInfo[playerid][pEmail], 32 , inputtext);
- bagaj = CreatePickup(1210, 1, 266.9013,96.4856,1033.3784, -1); //Virtual World (-1) is all worlds
- ShowPlayerDialog(playerid, DIALOG_TUTORIAL_COLECTARE_BAGAJ, DIALOG_STYLE_MSGBOX, "Caption", "Ai colectat valiza!\nTe poti indrepta catre iesire!", "Ok", "");
- }
- case DIALOG_LOGIN: {
- if(!response)
- return Kick(playerid);
- mysql_format(SQL, gQuery, sizeof(gQuery), "SELECT * FROM `users` WHERE `Name`='%s' AND `Password`='%s' LIMIT 1",GetName(playerid), inputtext);
- mysql_tquery(SQL, gQuery, "onLogin", "i", playerid);
- }
- }
- return 1;
- }
- CMD:teleport(playerid,params[])//the command
- {//first bracket
- new Float:x;//pos x
- new Float:y;//oos y
- new Float:z;//pos z
- new interior;
- new string[128];//the message string
- if(sscanf(params,"fffi", Float:x, Float:y, Float:z,interior)) return SendClientMessage(playerid, -1,"{FF0000}Error:{FFFFFF}/teleport [x] [y] [z] [interior]");//the message
- format(string,sizeof(string),"You have been teleported to coordinates: %.0f.%.0f.%.0f interior: %d",x,y,z,interior);//this is the format for our message
- SendClientMessage(playerid,-1,string);//now let's send him this message with the coordinates!
- SetPlayerInterior(playerid,interior);//now we will set the player interior
- SetPlayerPos(playerid,Float:x,Float:y,Float:z);//now let's teleport him to this pos!
- return 1;
- }
- stock GetName(playerid) {
- new playerName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
- return playerName;
- }
- function checkAccount(playerid) {
- switch(cache_num_rows()) {
- case 0:
- {
- Streamer_Update(playerid);
- PlayerTimers[playerid][1] = SetTimerEx("PlayerIntroCallback", 4000, 0, "id", playerid, 0);
- Streamer_Update(playerid);
- }
- case 1: ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Scrie parola pentru a te putea autentifica", "Select", "Cancel");
- }
- return 1;
- }
- function insertAccount(playerid) {
- PlayerInfo[playerid][pSQLID] = cache_insert_id();
- printf("$s s-a inregistrat cu SQLDID-ul #%d.", GetName(playerid), PlayerInfo[playerid][pSQLID]);
- return 1;
- }
- function onLogin(playerid) {
- switch(cache_num_rows()) {
- case 0: {
- incercariParola[playerid] ++;
- gString[0] = EOS;
- format(gString, sizeof(gString), "Parola incorecta! (%d/3 incercari ramase)", incercariParola[playerid]);
- SendClientMessage(playerid, COLOR_DARKRED, gString);
- if(incercariParola[playerid] == 3 ) Kick(playerid);
- else ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Scrie parola pentru a te putea autentifica", "Select", "Cancel");
- }
- case 1: {
- new
- result[64];
- PlayerInfo[playerid][pSQLID] = cache_get_field_content_int(0, "ID");
- cache_get_field_content(0, "Name", result);format(PlayerInfo[playerid][pName], MAX_PLAYER_NAME, result);
- cache_get_field_content(0, "Password", result);format(PlayerInfo[playerid][pPassword], 32, result);
- cache_get_field_content(0, "Email", result);format(PlayerInfo[playerid][pEmail], 32, result);
- cache_get_field_content(0, "Tutorial", result);format(PlayerInfo[playerid][pTutorial], 32, result);
- printf("%s (user: %d) tocmai s-a logat.", GetName(playerid), PlayerInfo[playerid][pSQLID]);
- SpawnPlayer(playerid);
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement