[Ajuda] Fixar comando dar DP on/off MYSQL
#1

Tentei fazer o comando de dar DP online/offline com MYSQL, seguindo alguns tуpicos aqui do fуrum, mas nгo consegui, alguйm me ajuda a fixar?

Erros nos comentarios (//)
Код:
CMD:givedp(playerid, params[]) {
	new player[MAX_PLAYER_NAME], quantidade, string[128];
	if(sscanf(params,"si", player, quantidade)) return SendClientMessage(playerid, -1, "Use: /givedp [player-name] [ammount]");

	new idplayer;
	idplayer = GetPlayerIdFromName(player);
	if(idplayer >= 0) {
		idplayer = GetPlayerIdFromName(player);
		DP[idplayer] += quantidade;
		format(string, sizeof(string), "O admin %s adicionou %i DONATE POINTS para %s (ONLINE)", PlayerName(playerid), quantidade, PlayerName(idplayer) );
		SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
		SendClientMessage(idplayer, COLOR_LIGHTBLUE, string);
	}
	else {
		new rows, fields;
		cache_get_data(rows, fields);
		if (!rows) return SendClientMessage(playerid, -1, "Nгo hб nenhum player com esse nome.");
		
		new query[200], dpatual;
		format(query, sizeof(query), "SELECT * FROM accounts WHERE Username='%s'", player);
		mysql_query(ConnectMYSQL,query);
		mysql_store_result(); // error 017: undefined symbol "mysql_store_result"
		while(mysql_fetch_row_format(query,"|")) // error 017: undefined symbol "mysql_fetch_row_format"
		{
			dpatual = cache_get_field_content_int(0, "DP");
		}
		mysql_free_result(); // error 017: undefined symbol "mysql_store_result"
		format(query, sizeof(query), "UPDATE accounts SET DP=%d WHERE Username='%s'",
		dpatual + quantidade,
		player);
		mysql_query(ConnectMYSQL,query);
		format(string, sizeof(string), "O admin %s adicionou %i DONATE POINTS para %s (OFFLINE)", PlayerName(playerid), quantidade, player );
		SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
		SendClientMessage(idplayer, COLOR_LIGHTBLUE, string);
	}
	return 1;
}
Reply
#2

Alguйm por favor poderia me ajudar?
Reply
#3

alguйm sabe?
Reply
#4

Olб pessoal? Os erros estгo sу aqui
Код:
		mysql_store_result(); // error 017: undefined symbol "mysql_store_result"
		while(mysql_fetch_row_format(query,"|")) // error 017: undefined symbol "mysql_fetch_row_format"
		{
			dpatual = cache_get_field_content_int(0, "DP");
		}
		mysql_free_result(); // error 017: undefined symbol "mysql_store_result"
Reply
#5

alguйm?
Reply
#6

alguйm?
Reply
#7

https://sampforum.blast.hk/showthread.php?tid=56564
Reply
#8

Tб tudo errado amigo, usando funзхes da R5 na R7/R33+
Reply
#9

Olб warriorfrog, aqui estб o comando funcional:
Код:
CMD:givedp(playerid, params[])
{
	new Nameid[25], valor,string[128],query[160],idplayer;
	if(sscanf(params,"s[25]i", Nameid, valor))
		return SendClientMessage(playerid, -1, "Use: /givedp [player-name] [ammount]");

    idplayer = GetPlayerIdFromName(Nameid);
	if(IsPlayerConnected(idplayer))
	{
		DP[idplayer] += valor;
		format(string, sizeof(string), "O admin %s adicionou %i DONATE POINTS para %s (ONLINE)", PlayerName(playerid), valor, PlayerName(idplayer));
		SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
		SendClientMessage(idplayer, COLOR_LIGHTBLUE, string);
	}else{
		mysql_format(ConnectMYSQL, query, sizeof query, "SELECT `Username`, `DP` FROM accounts WHERE Username = '%e' LIMIT 1", Nameid);
		mysql_tquery(ConnectMYSQL, query, "AddDP", "isi", playerid, Nameid, valor);
	}
	return true;
}

forward AddDP(playerid, Nameid[], valor);
public AddDP(playerid, Nameid[], valor)
{
	new query[200], string[128];
	if(cache_get_row_count(ConnectMYSQL) == 1)
	{
	    dpatual = cache_get_field_content_int(0, "DP");
	    
		mysql_format(ConnectMYSQL, query, sizeof query, "UPDATE accounts SET DP = '%d' WHERE Username = '%s'", dpatual+valor, Nameid);
		mysql_tquery(ConnectMYSQL, query, "", "");

		format(string, sizeof(string), "O admin %s adicionou %i DONATE POINTS para %s (OFFLINE)", PlayerName(playerid), valor, Nameid);
		SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
	}
	else
	    SendClientMessage(playerid, -1, "Nгo hб nenhum player com esse nome.");
	return true;
}
Reply
#10

Quote:
Originally Posted by cicinho
Посмотреть сообщение
Olб warriorfrog, aqui estб o comando funcional:
Код:
CMD:givedp(playerid, params[])
{
	new Nameid[25], valor,string[128],query[160],idplayer;
	if(sscanf(params,"s[25]i", Nameid, valor))
		return SendClientMessage(playerid, -1, "Use: /givedp [player-name] [ammount]");

    idplayer = GetPlayerIdFromName(Nameid);
	if(IsPlayerConnected(idplayer))
	{
		DP[idplayer] += valor;
		format(string, sizeof(string), "O admin %s adicionou %i DONATE POINTS para %s (ONLINE)", PlayerName(playerid), valor, PlayerName(idplayer));
		SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
		SendClientMessage(idplayer, COLOR_LIGHTBLUE, string);
	}else{
		mysql_format(ConnectMYSQL, query, sizeof query, "SELECT `Username`, `DP` FROM accounts WHERE Username = '%e' LIMIT 1", Nameid);
		mysql_tquery(ConnectMYSQL, query, "AddDP", "isi", playerid, Nameid, valor);
	}
	return true;
}

forward AddDP(playerid, Nameid[], valor);
public AddDP(playerid, Nameid[], valor)
{
	new query[200], string[128];
	if(cache_get_row_count(ConnectMYSQL) == 1)
	{
	    dpatual = cache_get_field_content_int(0, "DP");
	    
		mysql_format(ConnectMYSQL, query, sizeof query, "UPDATE accounts SET DP = '%d' WHERE Username = '%s'", dpatual+valor, Nameid);
		mysql_tquery(ConnectMYSQL, query, "", "");

		format(string, sizeof(string), "O admin %s adicionou %i DONATE POINTS para %s (OFFLINE)", PlayerName(playerid), valor, Nameid);
		SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
	}
	else
	    SendClientMessage(playerid, -1, "Nгo hб nenhum player com esse nome.");
	return true;
}
Parece estar funcionando! Muito obrigado!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)