Jump to content

Jakewow

Member
  • Posts

    130
  • Joined

  • Last visited

Posts posted by Jakewow

  1. 10 minutes ago, Leonard said:

    N-ai cum sa trimiti ceva in baza de date fara sa formatezi.

    eu nu vreau sa folosesc 

    new string[256];
    format(string, sizeof(string), "Admin %s promoted %s to admin level %d.", GetName(playerid), GetName(id), level);

    se poate fara?

  2. 5 minutes ago, whorT said:
    
    new string[256];
    format(string, sizeof(string), "Admin %s promoted %s to admin level %d.", GetName(playerid), GetName(id), level);
    AdminLogs(string);
    
    function AdminLogs(string[]) {
        new query[512];
        mysql_format(SQL, query, 512, "INSERT INTO adminlogs (`info`) VALUES ('%s')", string);
        mysql_query(SQL, query);
        return 1;
    }

     

    da, faza e ca nu vreau sa folosesc format..

  3. unde iti spune warning 217: loose indentation inseamna ca nu e codul in rand cu celelalte linii adica mai adauga TAB-uri
    unde iti spune ca warning 204: symbol is assigned a value that is never used: "string7"  inseamna ca tu la linia 4565 ai facut new string7[numar]; sterge acel string7[numar];
    unde iti spune error 017: undefined symbol "string" inseamna ca tu trebuie sa definesti undeva new string[256];

  4. dece ai face un server pe orm?

    Why should I replace cache with ORM ?

    ORM-code is way easier to maintain. With the normal cache-stuff, you'd have to edit the code in several places in your script if you wan't to add a new variable and you also would need to edit some queries. With the ORM-system, all you need to do is to add one line.

     

    Topicul original ORM.

     

    Daca nu stii engleza naspa..

  5. multumesc.

     

    dar stiti cum pot face sa nu trb sa dau admin si din baza de date??? deoarece daca dau cu /setadmin cand da relog ii se scoate admin si trb sa ii bag din baza de date

    E mult de explicat incepe si tu pe alt gm trebuie sa scoti securitatea pnm..

  6. Aici ai /setadmin :

    CMD:setadmin(playerid, params[]) {
    
    	new id, adminlevel, gString[120];
    
    	if(PlayerInfo[playerid][pAdmin] < 6)
    		return SCM(playerid, COLOR_WHITE, AdminOnly);
    
    	if(sscanf(params, "ui", id, adminlevel))
    		return SCM(playerid, COLOR_GREY, "USAGE: {FFFFFF}/setadmin <playerid/name> <Admin Level>");
    
    	if(!IsPlayerConnected(id) || id == INVALID_PLAYER_ID)
    		return SCM(playerid, COLOR_GREY, "Acel player nu este conectat.");
    
    	if(adminlevel < 0 || adminlevel > 6)
    		return SCM(playerid, COLOR_GREY, "Invalid admin level. 0-6");
    
    	if(PlayerInfo[id][pAdmin] > PlayerInfo[playerid][pAdmin])
    		return SCM(playerid, COLOR_GREY, "Nu poti folosi aceasta comanda pe acel player. Are admin level mai mare.");
    
    	format(gString, 80, "Ai fost promovat la admin %d de %s", adminlevel, GetName(playerid));
    	SCM(id, COLOR_LIGHTBLUE, gString);
    
    	format(gString, 100, "System: %s i-a setat lui %s admin level %d.", GetName(playerid), GetName(id), adminlevel);
    	SendAdminHelperMessage(COLOR_LOGS, gString);
    
    	if(adminlevel == 0) {
    		PlayerInfo[id][pAW] = 0;
    		UpdateVar(id, "AW", 0);
    		SpecFaction[id] = 0;
    		StopFly(playerid);
    		UsedFly[playerid] = 0;
    		SetPlayerHealthEx(playerid, 100);
    
    		Iter_Remove(PlayerAdmins, id);
    	}
    
    	Iter_Add(PlayerAdmins, id);
    
    	finishAchievement(id, 27);
    	PlayerInfo[id][pAdmin] = adminlevel;
    
    	new gQuery[180];
    
    	if(adminlevel >= 1)
    		format(gQuery, sizeof(gQuery), "UPDATE users SET `Admin`='%d', `Security`='%s', `HelpedPlayers`='0' WHERE `ID`='%d'", PlayerInfo[id][pAdmin]/*, MD5_Hash(DEFAULT_PASSWORD)*/, PlayerInfo[id][pSQLID]);
    	else
    		UpdateVar(id, "Admin", PlayerInfo[id][pAdmin]);
    	mysql_tquery(SQL, gQuery, "", "");
    	SetPVarInt(id, "SecurityPlayer", 0);
    
    	return true;
    }
    

    Aici ai /sethelper :

    CMD:sethelper(playerid, params[]) {
    
    	new id, gString[180], helperlevel;
    
    	if(PlayerInfo[playerid][pAdmin] < 6)
    		return SCM(playerid, COLOR_WHITE, AdminOnly);
    
    	if(sscanf(params, "ui", id, helperlevel))
    		return SCM(playerid, COLOR_GREY, "USAGE: {FFFFFF}/sethelper <playerid/name> <level(0-3)>");
    
    	if(!IsPlayerConnected(id) || id == INVALID_PLAYER_ID)
    		return SCM(playerid, COLOR_GREY, "Acel player nu este conectat.");
    
    	if(helperlevel == 0) {
    		Iter_Remove(HelpersDuty, 0);
    		HaveHelp[playerid] = -1;
    
    		format(gString, sizeof(gString), "Ai fost scos din functia de helper de catre %s", GetName(playerid));
    		SCM(id, COLOR_LIGHTBLUE, gString);
    
    		format(gString, sizeof(gString), "System: %s a fost scos din fucntia de helper level %d de catre %s", GetName(id), helperlevel, GetName(playerid));
    		SendAdminHelperMessage(COLOR_LOGS, gString);
    
    		PlayerInfo[id][pHW] = 0;
    		UpdateVar(id, "HW", 0);
    		NewbieChat[id] = 0;
    
    		Iter_Remove(PlayerHelpers, playerid);
    
    	}
    
    	Iter_Add(PlayerHelpers, playerid);
    	PlayerInfo[id][pHelper] = helperlevel;
    
    	format(gString, sizeof(gString), "Ai fost promovat ca helper level %d de %s.", helperlevel, GetName(playerid));
    	SCM(id, COLOR_LIGHTBLUE, gString);
    
    	format(gString, sizeof(gString), "System: %s i-a setat lui %s helper level %d", GetName(playerid), GetName(id), helperlevel);
    	SendAdminHelperMessage(COLOR_LOGS, gString);
    
    	finishAchievement(id, 26);
    
    	new gQuery[128];
    
    	format(gQuery, sizeof(gQuery), "UPDATE users SET `Helper`='%d', `HelpedPlayers`='0' WHERE `ID`='%d'", helperlevel, PlayerInfo[id][pSQLID]);
    	mysql_tquery(SQL, gQuery, "", "");
    
    	return true;
    }
    
  7. Tot nu merge, se opreste la if(cache_get_row_count() == 0) return SCM(playerid, -1, "Nu am gasit nici un urat in baza de date.");

    CMD:showuratii(playerid, params[]) {
    	if(PlayerInfo[playerid][pAdmin] <= 4) return 1;
    	new query[256];
    	mysql_format(SQL, query, sizeof(query), "SELECT * FROM `urati` ORDER BY `id` DESC");
    	mysql_tquery(SQL, query, "", "");
    	if(cache_get_row_count() == 0) return SCM(playerid, -1, "Nu am gasit nici un urat in baza de date.");
    	new id, NUME[32], IDJOC, string[512];
    	for(new i = 0; i < cache_num_rows(); i++) {
    		id = cache_get_field_content_int(i, "id");
    		cache_get_field_content(i, "NUME", NUME, SQL, 128);
    		IDJOC = cache_get_field_content_int(i, "IDJOC");
    		format(string, sizeof(string), "%d -> %s -> %s\n", id, NUME, IDJOC);
    		printf("%d -> %s -> %s\n", id, NUME, IDJOC);
    	}
    	ShowPlayerDialog(playerid, DIALOG_URATI, DIALOG_STYLE_MSGBOX, "Lista cu urati", string, "Ok", "");
    	SCM(playerid, -1, string);
    	return 1;
    }
    
  8.  

    Cand vad "Cache:" -ul ala ma iau durerile de cap...

    CMD:uratii(playerid, params[])
    {
    	if(PlayerInfo[playerid][pAdmin] <= 4) return 1;
    
    	new gQuery[0] = (EOS);
    	mysql_format(SQL, gQuery, sizeof gQuery, "SELECT * FROM `urati` ORDER BY `id` DESC");
    	mysql_tquery(SQL, gQuery, "arataUratii", "d", "playerid");
    
    	return 1;
    }
    
    function arataUratii(playerid)
    {
    	if(cache_get_row_count() == 0) return SCM(playerid, -1, "Nu am gasit nici un urat in baza de date.");
    
    	new id, nick[32], idjoc, string[512];
    
    	for(new i = 0; i < cache_num_rows(); i++) 
    	{
    		id = cache_get_field_content_int(i, "id");
    		getString(i, "NUME", nick, SQL, 128);
    		idjoc = cache_get_field_content_int(i, "IDJOC");	
    
    		format(string, sizeof string, "%d -> %s -> %d\n", id, nick, idjoc);
    	}
    
    	ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "Lista cu urati", string, "Ok", "");
    
    	return 1;
    }
    

    imi da o eroare cu getstring nedefinit

  9. Am incercat cu for..

    Eu am in acel tabel 7 randuri inserate https://imgur.com/a/AIDSKTj

    coloana id are INT(2) si e pe AUTO_INCREMENT
    restul coloanelor (NUME, IDJOC) sunt cu TEXT

     Aici am comanda cu for dar nu imi da nimic, imi da pur si simplu o singura linie cu 0 cand o testez

    CMD:showuratii(playerid, params[]) {
    	if(PlayerInfo[playerid][pAdmin] <= 4) return SCM(playerid, -1, "");
    	new query[128];
    	format(query, sizeof(query), "SELECT * FROM `urati`");
    	new Cache: result, id, nick, idjoc, szResult[256];
    	result = mysql_query(SQL, query);
    	for(new i, j = cache_get_row_count (); i < j; i++) {
    		cache_get_field_content(0, "id", szResult); id = strval(szResult);
    		cache_get_field_content(0, "NUME", szResult); nick = strval(szResult);
    		cache_get_field_content(0, "IDJOC", szResult); idjoc = strval(szResult);
    	}
    	cache_delete(result);
    	new string[128];
    	format(string, sizeof(string), "%d -> %s -> %s \n.",id, nick, idjoc);
    	SCM(playerid, -1, string);
    	return 1;
    }
    
  10. Salut

     

    Deci am in DB un tabel numit 'urati' in care am coloanele `id` `NUME` `IDJOC`

     

    In acel tabel se stocheaza niste useri

     

    Eu vreau sa fac o comanda spre exemplu /showurati in care sa-mi arate prin SCM toti userii stocati in acel tabel

     

    Ce am reusit eu pana acum :

    CMD:uratii(playerid, params[]) {
    	if(PlayerInfo[playerid][pAdmin] <= 4) return SCM(playerid, -1, "");
    	new query[128];
    	format(query, sizeof(query), "SELECT * FROM `urati`");
    	new Cache: result, id, nick, idjoc, szResult[256];
    	result = mysql_query(SQL, query);
    	cache_get_field_content(0, "id", szResult); id = strval(szResult);
    	cache_get_field_content(0, "NUME", szResult); nick = strval(szResult);
    	cache_get_field_content(0, "IDJOC", szResult); idjoc = strval(szResult);
    	cache_delete(result);
    	new string[128];
    	format(string, sizeof(string), "%d -> %s -> %s \n.",id, nick, idjoc);
    	SCM(playerid, -1, string);
    	return 1;
    }
    

    Doar ca nu-mi da nimic... iar in tabel am 5 linii puse asa de test

×
×
  • Create New...