Problem with an unban cmd
#1

This is the cmd:

Код:
CMD:aunban(playerid,params[])
{
	if(pInfo[playerid][Admin] >= 70)
	{
		new nom[24],string[128];
		if(sscanf(params,"s[24]", nom)) return SendClientMessage(playerid, Gris, "/aunban [Nom_Prйnom du joueur]");
		format(string, sizeof(string), "SELECT * FROM `joueurs` WHERE `Bannis` = '1' AND `Username` = '%s' LIMIT 1", nom);
		mysql_query(string);
		mysql_store_result();
		if(!mysql_num_rows()) return mysql_free_result();
		SendClientMessage(playerid, Rouge,"Ce joueur n'est pas bannis !");
		mysql_free_result();
		mysql_format(mysql,string,sizeof(string),"UPDATE `joueurs` SET `Bannis` = '0' WHERE `Username` = '%e'", nom);
		mysql_tquery(mysql,string,"","");
		GetPlayerName(playerid, joueuremetteur, sizeof(joueuremetteur));
		GetPlayerName(nom, joueurdestinataire, sizeof(joueurdestinataire));
		format(string, sizeof(string), "%s a unban %s.", joueuremetteur, joueurdestinataire);
		ChannelAdmin(Rouge, string);
		return 1;
	}
	return SendClientMessage(playerid, Rouge,"La commande entrйe est inconnue !");
}
But I got errors:

Код:
mysql_query(string);
 error 035: argument type mismatch (argument 1)
Код:
mysql_store_result();
warning 209: function "mysql_free_result" should return a value
Reply
#2

Which plugin version are you using? BlueG's R7 wont allow non threaded queries as the function mysql_query is not even supported.

If you're using BlueG's R7 update to R34 (not R35), it will support non threaded queries in the way you use them.

------

mysql_query haves more than 1 parameter:

mysql_query(conhandle, query[], bool:use_cache = true)



As for mysql_store_result(), that callback is not supported at R34 as it uses cache data instead.

https://sampwiki.blast.hk/wiki/MySQL/R33#mysql_query for further documentation on callbacks.
Reply
#3

Thank you,


I'm using R36 plugin, so what should I correct to have a cmd that compile and work please ?

Thank you.
Reply
#4

Quote:
Originally Posted by anou1
Посмотреть сообщение
Thank you,


I'm using R36 plugin, so what should I correct to have a cmd that compile and work please ?

Thank you.
Depends, read the numerous guides that are around which explain how to threat cached data. I recommend using threaded queries too. Once again, there are numerous guides around the forums; check the ones provided in the main plugin thread, these are pretty easy to understand.
Reply
#5

I tried to do this:

Код:
CMD:aunban(playerid, params[])
{
	if(pInfo[playerid][Admin] >= 70)
	{
		new nom[24], string[128], query[128];
		if(sscanf(params,"s[24]", nom)) return SendClientMessage(playerid, Gris, "/aunban [Nom_Prйnom du joueur]");
		format(query, sizeof(query), "SELECT * FROM `joueurs` WHERE `Bannis` = '1' AND `Username` = '%s' LIMIT 1", nom);
		mysql_tquery(mysql, query);
		mysql_store_result();
		if(!mysql_num_rows()) return cache_delete(query);
		SendClientMessage(playerid, Rouge, "Ce joueur n'est pas bannis !");
		cache_delete(query);
		mysql_format(mysql, query, sizeof(query),"UPDATE `joueurs` SET `Bannis` = '0' WHERE `Username` = '%e'", nom);
		mysql_tquery(mysql, query, "","");
		GetPlayerName(playerid, joueuremetteur, sizeof(joueuremetteur));
		format(string, sizeof(string), "%s a unban %s.", joueuremetteur, nom);
		ChannelAdmin(Rouge, string);
		return 1;
	}
	return SendClientMessage(playerid, Rouge,"La commande entrйe est inconnue !");
}
But the cache_delete(query) return an error:
Beta.pwn(1683) : error 035: argument type mismatch (argument 1)


https://sampwiki.blast.hk/wiki/MySQL/R33#cache_delete


I don't understand what's wrong with my cmd.

Could you please tell me how to correct this, and how should I do ?

Thank you.
Reply
#6

mysql_store_result(); Is not supported in the current versions of the plugin. You need to use the cache functions, not store results and num rows.
Reply
#7

Thank you but right now, I'm not able to do it myself, It's too complicated for me.


I don't usually ask for a code but now I tried all I was able to do and I'm still blocked.
Could someone please do it for me or give me the right code that work with R36 ?


if someone can ensure this command to work with R36:

Код:
CMD:aunban(playerid, params[])
{
	if(pInfo[playerid][Admin] >= 70)
	{
		new nom[24], string[128], query[128];
		if(sscanf(params,"s[24]", nom)) return SendClientMessage(playerid, Gris, "/aunban [Nom_Prйnom du joueur]");
		format(query, sizeof(query), "SELECT * FROM `joueurs` WHERE `Bannis` = '1' AND `Username` = '%s' LIMIT 1", nom);
		mysql_tquery(mysql, query);
		mysql_store_result();
		if(!mysql_num_rows()) return cache_delete(query);
		SendClientMessage(playerid, Rouge, "Ce joueur n'est pas bannis !");
		cache_delete(query);
		mysql_format(mysql, query, sizeof(query),"UPDATE `joueurs` SET `Bannis` = '0' WHERE `Username` = '%e'", nom);
		mysql_tquery(mysql, query, "","");
		GetPlayerName(playerid, joueuremetteur, sizeof(joueuremetteur));
		format(string, sizeof(string), "%s a unban %s.", joueuremetteur, nom);
		ChannelAdmin(Rouge, string);
		return 1;
	}
	return SendClientMessage(playerid, Rouge,"La commande entrйe est inconnue !");
}
Thank you.
Reply
#8

I don't really know how to use non threaded queries so this code is a threaded query example:

pawn Код:
CMD:aunban(playerid, params[])
{
    if(pInfo[playerid][Admin] < 70)
        return SendClientMessage(playerid, Rouge,"La commande entrйe est inconnue !");
       
    new nom[24], string[128], query[128];
    if(sscanf(params,"s[24]", nom)) return SendClientMessage(playerid, Gris, "/aunban [Nom_Prйnom du joueur]");
    format(query, sizeof(query), "SELECT * FROM `joueurs` WHERE `Bannis` = '1' AND `Username` = '%s' LIMIT 1", nom);
    mysql_tquery(mysql, query, "OnPlayerRequestUnbanData","is",playerid,nom);
    return 1;
}

forward OnPlayerRequestUnbanData(playerid,nom[]);
public OnPlayerRequestUnbanData(playerid,nom[])
{
    new string[128], query[128];
    if(!cache_get_row_count())
    {
        SendClientMessage(playerid, Rouge, "Ce joueur n'est pas bannis !");
        return 1;
    }

    mysql_format(mysql, query, sizeof(query),"UPDATE `joueurs` SET `Bannis` = '0' WHERE `Username` = '%e'", nom);
    mysql_tquery(mysql, query, "","");
    GetPlayerName(playerid, joueuremetteur, sizeof(joueuremetteur));
    format(string, sizeof(string), "%s a unban %s.", joueuremetteur, nom);
    ChannelAdmin(Rouge, string);
    return 1;
}
Reply
#9

Thank you so much !!!

I will try this asap !

+Rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)