Jump to content

sRk7

Members
  • Posts

    42
  • Joined

  • Last visited

Everything posted by sRk7

  1. sRk7

    Move Object

    http://wiki.sa-mp.com http://wiki.sa-mp.com/wiki/MoveObject http://wiki.sa-mp.com/wiki/IsPlayerInRangeOfPoint
  2. if(GetPlayerState(i) == PLAYER_STATE_DRIVER && InDealer[i] == 0 || GetPlayerState(i) == PLAYER_STATE_PASSENGER && InDealer[i] == 0) {
  3. Ti-l recomand cu incredere. https://www.sa-mp.ro/forums/topic/26125-gamemode-saints-net-v145-v148/
  4. InterpolateCameraPos(playerid, x, y, z, c, speed, CAMERA_MOVE); InterpolateCameraLookAt(playerid, x, y, z, x1, y1, z1, speed, CAMERA_MOVE); x, y, z = pozitia de start a camerei x1, y1, z1 = pozitia de final a camerei speed = viteaza de miscare intre start si sfarsit.
  5. sRk7

    Random

    Pentru ca 10/100 = 0.10 nu 10.
  6. sRk7

    Random

    ew Float: div = floatdiv(random(100), 100), result[15]; div = un numar random (0 - 100) divizat la 100, result = stocheaza numarul din div, si il transforma intrun string. floatstr(result) > 0.00 = daca numarul din result este mai mare de ( 0.00 && 0.10 ) mai mic sau egal cu 0.10 ii acorda un premiu rar de exemplu.
  7. sRk7

    Random

    CMD:roll(playerid, params[]) { new Float: div = floatdiv(random(100), 100), result[15]; format(result, sizeof(result), "%.2f", div); // Stocheaza numarul care a fost ales. if(floatstr(result) > 0.00 && floatstr(result) < 0.10) { // Legendar (Foarte greu sa pice, o sansa foarte mica) SendClientMessage(playerid, -1, "{ff9900}Ai castigat un premiu legendar. Urmareste checkpoint pentru a il vinde."); SetPlayerCheckpoint(playerid, 1982.6150, -220.6680, -0.2432, 3.0); } if(floatstr(result) > 0.10 && floatstr(result) <= 0.35) { SendClientMessage(playerid, -1, "{99cc00}Ai castigat un premiu rar. Urmareste checkpoint pentru a il vinde."); SetPlayerCheckpoint(playerid, 1982.6150, -220.6680, -0.2432, 3.0); } if(floatstr(result) > 0.35) { SendClientMessage(playerid, -1, "{666633}Ai castigat un premiu comun. Urmareste checkpoint pentru a il vinde."); SetPlayerCheckpoint(playerid, 1982.6150, -220.6680, -0.2432, 3.0); } return 1; } Sper ca asta doresti.
  8. new query[256]; mysql_format(SQL, query, sizeof(query), "UPDATE `users` SET `Security`='%s' WHERE `ID`='%d'", MD5_Hash(key), PlayerInfo[playerid][pSQLID]); mysql_tquery(SQL, query, "", ""); format(PlayerInfo[id][pSecurity], 64, MD5_Hash(key)); Foloseste MD5 pentru criptare in baza de date, verifica cand introduce key sa fie si aia criptata in MD5
  9. new PlayerJobVeh[MAX_PLAYERS] = INVALID_VEHICLE_ID, PlayerJobTRAILER[MAX_PLAYERS] = INVALID_VEHICLE_ID; forword TrailerTimer(playerid) public TrailerTimer(playerid) { if(PlayerJobTRAILER[playerid] == INVALID_VEHICLE_ID && PlayerJobVeh[playerid] == INVALID_VEHICLE_ID) return 0; new trailerid = GetVehicleTrailer(PlayerJobVeh[playerid]); if(!IsTrailerAttachedToVehicle(PlayerJobVeh[playerid])) { // Daca nu il mai are atasat AttachTrailerToVehicle(PlayerJobTRAILER[playerid], PlayerJobVeh[playerid]); } return 1; } La OnPlayerConnect SetTimerEx("TrailerTimer", 1000, true, "d", playerid); Atunci cand dai /work sau cum ai tu, setazi asa: PlayerJobTRAILER[playerid] = CreateVehicle(...); PlayerJobVeh[playerid] = CreateVehicle(...); Iar cand termina cursa ii resetezi trailer. PlayerJobTRAILER[playerid] = INVALID_VEHICLE_ID; Asta ii va stoca la player ce masina are si ce trailer. Indiferent de player
  10. Vezi asa: new vehicleidJob = CreateVehicle(...); // Masina de la job new traileridJob = CreateVehicle(...); // Trailer-ul de la job forword TrailerTimer() public TrailerTimer() { new trailerid = GetVehicleTrailer(vehicleidJob); if(!IsTrailerAttachedToVehicle(vehicleidJob)) { // Daca nu il mai are atasat AttachTrailerToVehicle(trailerid, vehicleidJob); } } SetTimer("TrailerTimer", 1000, 1);
  11. Probabil nu ai pus size cum trebuie, iti sugerez sa urmezi acest tutorial:https://www.youtube.com/watch?v=xgR5wI6N-6M
  12. CMD:mergedata(playerid, params[]) { new date[3]; getdate(date[2], date[1], date[0]); if(date[2] == 2018 && date[1] == 1 && date[0] == 1) { face ce vrei pe data asta } else { SendClientMessage(playerid, -1, "Aceasta comanda poate fii folosita doar pe data de [01.01.2018]"); } return 1; }
  13. O sa iti las aici un fs cu un sistem de register/login simplu, dupa care il poti modifica dupa bunul plac. Codul pentru FS: #include <a_samp> #include <a_mysql> #if defined FILTERSCRIPT // MySQL configuration #define MYSQL_HOST "127.0.0.1" #define MYSQL_USER "username" #define MYSQL_PASSWORD "password" #define MYSQL_DATABASE "database" // how many seconds until it kicks the player for taking too long to login #define SECONDS_TO_LOGIN 30 // default spawn point: Las Venturas (The High Roller) #define DEFAULT_POS_X 1958.3783 #define DEFAULT_POS_Y 1343.1572 #define DEFAULT_POS_Z 15.3746 #define DEFAULT_POS_A 270.1425 // MySQL connection handle new MySQL: g_SQL; // player data enum E_PLAYERS { ID, Name[MAX_PLAYER_NAME], Password[65], // the output of SHA256_PassHash function (which was added in 0.3.7 R1 version) is always 256 bytes in length, or the equivalent of 64 Pawn cells Salt[17], Kills, Deaths, Float: X_Pos, Float: Y_Pos, Float: Z_Pos, Float: A_Pos, Interior, Cache: Cache_ID, bool: IsLoggedIn, LoginAttempts, LoginTimer }; new Player[MAX_PLAYERS][E_PLAYERS]; new g_MysqlRaceCheck[MAX_PLAYERS]; // dialog data enum { DIALOG_UNUSED, DIALOG_LOGIN, DIALOG_REGISTER }; public OnFilterScriptInit() { new MySQLOpt: option_id = mysql_init_options(); mysql_set_option(option_id, AUTO_RECONNECT, true); // it automatically reconnects when loosing connection to mysql server g_SQL = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE, option_id); // AUTO_RECONNECT is enabled for this connection handle only if (g_SQL == MYSQL_INVALID_HANDLE || mysql_errno(g_SQL) != 0) { print("MySQL connection failed. Server is shutting down."); SendRconCommand("exit"); // close the server if there is no connection return 1; } print("MySQL connection is successful."); // if the table has been created, the "SetupPlayerTable" function does not have any purpose so you may remove it completely SetupPlayerTable(); return 1; } public OnFilterScriptExit() { // save all player data before closing connection for (new i = 0, j = GetPlayerPoolSize(); i <= j; i++) // GetPlayerPoolSize function was added in 0.3.7 version and gets the highest playerid currently in use on the server { if (IsPlayerConnected(i)) { // reason is set to 1 for normal 'Quit' OnPlayerDisconnect(i, 1); } } mysql_close(g_SQL); return 1; } #else main() { print("\n----------------------------------"); print(" Blank Gamemode by your name here"); print("----------------------------------\n"); } #endif public OnGameModeInit() { SetGameModeText("Blank Script"); AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); return 1; } public OnGameModeExit() { return 1; } public OnPlayerRequestClass(playerid, classid) { SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746); SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746); SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746); return 1; } public OnPlayerConnect(playerid) { g_MysqlRaceCheck[playerid]++; // reset player data static const empty_player[E_PLAYERS]; Player[playerid] = empty_player; GetPlayerName(playerid, Player[playerid][Name], MAX_PLAYER_NAME); // send a query to recieve all the stored player data from the table new query[103]; mysql_format(g_SQL, query, sizeof query, "SELECT * FROM `players` WHERE `username` = '%e' LIMIT 1", Player[playerid][Name]); mysql_tquery(g_SQL, query, "OnPlayerDataLoaded", "dd", playerid, g_MysqlRaceCheck[playerid]); return 1; } public OnPlayerDisconnect(playerid, reason) { g_MysqlRaceCheck[playerid]++; UpdatePlayerData(playerid, reason); // if the player was kicked (either wrong password or taking too long) during the login part, remove the data from the memory if (cache_is_valid(Player[playerid][Cache_ID])) { cache_delete(Player[playerid][Cache_ID]); Player[playerid][Cache_ID] = MYSQL_INVALID_CACHE; } // if the player was kicked before the time expires (30 seconds), kill the timer if (Player[playerid][LoginTimer]) { KillTimer(Player[playerid][LoginTimer]); Player[playerid][LoginTimer] = 0; } // sets "IsLoggedIn" to false when the player disconnects, it prevents from saving the player data twice when "gmx" is used Player[playerid][IsLoggedIn] = false; return 1; } public OnPlayerSpawn(playerid) { // spawn the player to their last saved position SetPlayerInterior(playerid, Player[playerid][Interior]); SetPlayerPos(playerid, Player[playerid][X_Pos], Player[playerid][Y_Pos], Player[playerid][Z_Pos]); SetPlayerFacingAngle(playerid, Player[playerid][A_Pos]); SetCameraBehindPlayer(playerid); return 1; } public OnPlayerDeath(playerid, killerid, reason) { UpdatePlayerDeaths(playerid); UpdatePlayerKills(killerid); return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { switch (dialogid) { case DIALOG_UNUSED: return 1; // Useful for dialogs that contain only information and we do nothing depending on whether they responded or not case DIALOG_LOGIN: { if (!response) return Kick(playerid); new hashed_pass[65]; SHA256_PassHash(inputtext, Player[playerid][Salt], hashed_pass, 65); if (strcmp(hashed_pass, Player[playerid][Password]) == 0) { //correct password, spawn the player ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Login", "You have been successfully logged in.", "Okay", ""); // sets the specified cache as the active cache so we can retrieve the rest player data cache_set_active(Player[playerid][Cache_ID]); AssignPlayerData(playerid); // remove the active cache from memory and unsets the active cache as well cache_delete(Player[playerid][Cache_ID]); Player[playerid][Cache_ID] = MYSQL_INVALID_CACHE; KillTimer(Player[playerid][LoginTimer]); Player[playerid][LoginTimer] = 0; Player[playerid][IsLoggedIn] = true; // spawn the player to their last saved position after login SetSpawnInfo(playerid, NO_TEAM, 0, Player[playerid][X_Pos], Player[playerid][Y_Pos], Player[playerid][Z_Pos], Player[playerid][A_Pos], 0, 0, 0, 0, 0, 0); SpawnPlayer(playerid); } else { Player[playerid][LoginAttempts]++; if (Player[playerid][LoginAttempts] >= 3) { ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Login", "You have mistyped your password too often (3 times).", "Okay", ""); DelayedKick(playerid); } else ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Wrong password!\nPlease enter your password in the field below:", "Login", "Abort"); } } case DIALOG_REGISTER: { if (!response) return Kick(playerid); if (strlen(inputtext) <= 5) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registration", "Your password must be longer than 5 characters!\nPlease enter your password in the field below:", "Register", "Abort"); // 16 random characters from 33 to 126 (in ASCII) for the salt for (new i = 0; i < 16; i++) Player[playerid][Salt][i] = random(94) + 33; SHA256_PassHash(inputtext, Player[playerid][Salt], Player[playerid][Password], 65); new query[221]; mysql_format(g_SQL, query, sizeof query, "INSERT INTO `players` (`username`, `password`, `salt`) VALUES ('%e', '%s', '%e')", Player[playerid][Name], Player[playerid][Password], Player[playerid][Salt]); mysql_tquery(g_SQL, query, "OnPlayerRegister", "d", playerid); } default: return 0; // dialog ID was not found, search in other scripts } return 1; } //----------------------------------------------------- forward OnPlayerDataLoaded(playerid, race_check); public OnPlayerDataLoaded(playerid, race_check) { if (race_check != g_MysqlRaceCheck[playerid]) return Kick(playerid); new string[115]; if(cache_num_rows() > 0) { cache_get_value(0, "password", Player[playerid][Password], 65); cache_get_value(0, "salt", Player[playerid][Salt], 17); // saves the active cache in the memory and returns an cache-id to access it for later use Player[playerid][Cache_ID] = cache_save(); format(string, sizeof string, "This account (%s) is registered. Please login by entering your password in the field below:", Player[playerid][Name]); ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", string, "Login", "Abort"); // from now on, the player has 30 seconds to login Player[playerid][LoginTimer] = SetTimerEx("OnLoginTimeout", SECONDS_TO_LOGIN * 1000, false, "d", playerid); } else { format(string, sizeof string, "Welcome %s, you can register by entering your password in the field below:", Player[playerid][Name]); ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registration", string, "Register", "Abort"); } return 1; } forward OnLoginTimeout(playerid); public OnLoginTimeout(playerid) { // reset the variable that stores the timerid Player[playerid][LoginTimer] = 0; ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Login", "You have been kicked for taking too long to login successfully to your account.", "Okay", ""); DelayedKick(playerid); return 1; } forward OnPlayerRegister(playerid); public OnPlayerRegister(playerid) { // retrieves the ID generated for an AUTO_INCREMENT column by the sent query Player[playerid][ID] = cache_insert_id(); ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Registration", "Account successfully registered, you have been automatically logged in.", "Okay", ""); Player[playerid][IsLoggedIn] = true; Player[playerid][X_Pos] = DEFAULT_POS_X; Player[playerid][Y_Pos] = DEFAULT_POS_Y; Player[playerid][Z_Pos] = DEFAULT_POS_Z; Player[playerid][A_Pos] = DEFAULT_POS_A; SetSpawnInfo(playerid, NO_TEAM, 0, Player[playerid][X_Pos], Player[playerid][Y_Pos], Player[playerid][Z_Pos], Player[playerid][A_Pos], 0, 0, 0, 0, 0, 0); SpawnPlayer(playerid); return 1; } forward _KickPlayerDelayed(playerid); public _KickPlayerDelayed(playerid) { Kick(playerid); return 1; } //----------------------------------------------------- AssignPlayerData(playerid) { cache_get_value_int(0, "id", Player[playerid][ID]); cache_get_value_int(0, "kills", Player[playerid][Kills]); cache_get_value_int(0, "deaths", Player[playerid][Deaths]); cache_get_value_float(0, "x", Player[playerid][X_Pos]); cache_get_value_float(0, "y", Player[playerid][Y_Pos]); cache_get_value_float(0, "z", Player[playerid][Z_Pos]); cache_get_value_float(0, "angle", Player[playerid][A_Pos]); cache_get_value_int(0, "interior", Player[playerid][Interior]); return 1; } DelayedKick(playerid, time = 500) { SetTimerEx("_KickPlayerDelayed", time, false, "d", playerid); return 1; } SetupPlayerTable() { mysql_tquery(g_SQL, "CREATE TABLE IF NOT EXISTS `players` (`id` int(11) NOT NULL AUTO_INCREMENT,`username` varchar(24) NOT NULL,`password` char(64) NOT NULL,`salt` char(16) NOT NULL,`kills` mediumint(8) NOT NULL DEFAULT '0',`deaths` mediumint(8) NOT NULL DEFAULT '0',`x` float NOT NULL DEFAULT '0',`y` float NOT NULL DEFAULT '0',`z` float NOT NULL DEFAULT '0',`angle` float NOT NULL DEFAULT '0',`interior` tinyint(3) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `username` (`username`))"); return 1; } UpdatePlayerData(playerid, reason) { if (Player[playerid][IsLoggedIn] == false) return 0; // if the client crashed, it's not possible to get the player's position in OnPlayerDisconnect callback // so we will use the last saved position (in case of a player who registered and crashed/kicked, the position will be the default spawn point) if (reason == 1) { GetPlayerPos(playerid, Player[playerid][X_Pos], Player[playerid][Y_Pos], Player[playerid][Z_Pos]); GetPlayerFacingAngle(playerid, Player[playerid][A_Pos]); } new query[145]; mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `x` = %f, `y` = %f, `z` = %f, `angle` = %f, `interior` = %d WHERE `id` = %d LIMIT 1", Player[playerid][X_Pos], Player[playerid][Y_Pos], Player[playerid][Z_Pos], Player[playerid][A_Pos], GetPlayerInterior(playerid), Player[playerid][ID]); mysql_tquery(g_SQL, query); return 1; } UpdatePlayerDeaths(playerid) { if (Player[playerid][IsLoggedIn] == false) return 0; Player[playerid][Deaths]++; new query[70]; mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `deaths` = %d WHERE `id` = %d LIMIT 1", Player[playerid][Deaths], Player[playerid][ID]); mysql_tquery(g_SQL, query); return 1; } UpdatePlayerKills(killerid) { // we must check before if the killer wasn't valid (connected) player to avoid run time error 4 if (killerid == INVALID_PLAYER_ID) return 0; if (Player[killerid][IsLoggedIn] == false) return 0; Player[killerid][Kills]++; new query[70]; mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `kills` = %d WHERE `id` = %d LIMIT 1", Player[killerid][Kills], Player[killerid][ID]); mysql_tquery(g_SQL, query); return 1; }
  14. sRk7

    Ajutor

    FormatNumber(number, const separator[] = ",") { new output[15]; // longest possible output given 32 bit integers: -2,147,483,648 format(output, sizeof(output), "%d", number); for(new i = strlen(output) - 3; i > 0 && output[i-1] != '-'; i -= 3) { strins(output, separator, i); } return output; } Iar pentru utilizare: format(%0, %0, "X Are %s bani in mana", FormatNumber(GetPlayerMoney(playerid), ".")); format(%0, %0, "X Are %s bani in mana", FormatNumber(GetPlayerMoney(playerid)));
  15. 1. Ce fel de sistem de register/login vrei sa faci. 2. Pe ce vrei sa il faci?
  16. public OnPlayerConnect(playerid) { new MesajConnectare[128]; format(MesajConnectare,sizeof(MesajConnectare),"%s s-a connectat",pName(playerid)); SendClientMessageToAll(COLOR_GREY,MesajConnectare); print(MesajConnectare); LOGO[playerid] = CreatePlayerTextDraw(playerid, 58.500000, 423.955718, "Hyper23"); PlayerTextDrawLetterSize(playerid, LOGO[playerid], 0.400000, 1.600000); PlayerTextDrawTextSize(playerid, LOGO[playerid], -1.000000, 0.000000); PlayerTextDrawAlignment(playerid, LOGO[playerid], 1); PlayerTextDrawColor(playerid, LOGO[playerid], -1); PlayerTextDrawSetShadow(playerid, LOGO[playerid], 0); PlayerTextDrawBackgroundColor(playerid, LOGO[playerid], 255); PlayerTextDrawFont(playerid, LOGO[playerid], 1); PlayerTextDrawSetProportional(playerid, LOGO[playerid], 1); return 1; } stock pName(playerid) { new pName[MAX_PLAYER_NAME]; GetPlayerName(playerid, pName, sizeof(pName)); return pName; }
  17. sRk7

    /report

    Eroare: if(sscanf(params, "us[256]", result)) return SCM(playerid, -1, "/report <text>"); Normal, cam asa se face: if(sscanf(params, "us[256]", player, result)) return SCM(playerid, -1, "/report <text>"); Dar la tine poti face asa: if(sscanf(params, "s[128]", result)) return SCM(playerid, -1, "/report <text>"); Comanda ta, fara erori: CMD:report(playerid, params[]) { new result[256], string[128], name[MAX_PLAYER_NAME]; if(sscanf(params, "s[128]", string)) return SCM(playerid, -1, "/report <text>"); if(strlen(string) < 5) return SCM(playerid, -1, "Reportul tau este prea scurt, minim 5 caractere!"); if(Report[playerid] == 1) return SCM(playerid, -1, "Ai dat deja un report,asteapta un raspuns!"); Report[playerid] = 1; GetPlayerName(playerid, name, sizeof(name)); format(result, sizeof(result), "Report from %s (%d) : %s", name, playerid, string); SendAdminMessage(0xD90707FF, result); SendClientMessage(playerid, -1, "Report-ul tau a fost trimis adminilor!"); format(ReportText[playerid], sizeof(string), string); return 1; }
  18. sRk7

    Cine stie?

    https://pastebin.com/arJQgk47
  19. AK47, Deagle, AWP power.
  20. http://forum.bugged.ro/topic/285103-cine-stie/?p=3532216
  21. sRk7

    Cine stie?

    Incearca aste include, ar trebui sa rezolve problema ta. http://forum.sa-mp.com/showthread.php?t=291288&highlight=youtube
  22. sRk7

    Cine stie?

    Pentru toti playeri conectati? Sau ce vrei mai exact, ca nu inteleg...
  23. O sa iti fac eu un cod, cand o sa am timp, sigur vrei sa fie pe public FuncName()?
  24. sRk7

    Sistem Restart

    https://pastebin.com/9qfATcyr
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

moduri samp