Help with If's and Mysql
#1

How would i compare two mysql results? For example, I am checking if both players are in the same faction, if they are, the sender can kick the other one out of the faction, i've been wrapping my head around this and i have no clue how to do it.

Another question is how would i go on about to see if someone is the leader of the faction?

I am rather new to Pawn and most things are fairly different from php/java that i just can't understand it sometimes.

I'm sorry if this is a silly question, or a stupid question but i'm hoping someone can either explain the code, or somewhat explain other alternatives to me, me and my friend have been trying to fix this for 2 days and this part of the code is like the biggest wall so far.

I also have a couple more questions, some people use mysql_query, but on this script in particular it is different and mysql_query won't work, so i have this so far:
pawn Код:
CMD:fkick2(playerid, params[])
{
    new name[MAX_PLAYER_NAME];
    new mysql1; //I was hoping to store the queries in two variables and then compare them using a if
    new mysql2; //Would i use strcmp for that?
    SCM(playerid, COLOR_LIGHTRED, "Checkpoint1");
    if(sscanf(params,"u",name)) return SyntaxMSG(playerid, "/fkick2 [FirstName_LastName] use /fkick if the player is online");
    SCM(playerid, COLOR_LIGHTRED, "Checkpoint2");
    if(PlayerInfo[playerid][pFaction] == 0) return SCM(playerid, COLOR_LIGHTRED, "You're not in a faction!");
    SCM(playerid, COLOR_LIGHTRED, "Checkpoint3");
    if(strcmp(name, GetName(playerid), false))
    {
        SCM(playerid, COLOR_LIGHTRED, "Checkpoint4");
        format(query, sizeof(query), "SELECT `faction` FROM `users` WHERE `name` = '%s'", name);//What does the format do?
            mysql_function_query(dbHandle, query, false, "", "");//Will this run the query?
        mysql_store_result();//How does this work exactly?
            mysql_fetch_field("faction", mysql1);//trying to store the faction in the variable
            SCM(playerid, COLOR_LIGHTRED, "'%s'", mysql1);//trying to print it to the client to check if it's working
        SCM(playerid, COLOR_LIGHTRED, "Checkpoint5");
        SCM(playerid, COLOR_LIGHTRED, "Checkpoint6");
                //I've comented this next part because i don't know how to proceed
                //format(query, sizeof(query), "SELECT `faction` FROM `users` WHERE `name` = '%s'", GetName(playerid));
               //And now i just don't know , i've tried several things and i don't know how to compare those two queries
        /*if();
            {
                SCM(playerid, COLOR_INFO, "You have kicked out '%s' from your faction", name);
                format(query2, sizeof(query2), "UPDATE `users` SET `faction` = 0, `rank` = 0  WHERE `name` = '%s'", name);
                    mysql_function_query(dbHandle, query2, false, "", "");
            }*/

       
    }
    else
    {
        SCM(playerid, COLOR_LIGHTRED, "Wrong name format/You may not kick yourself.");
    }
    mysql_free_result();
    return 1;
}
Reply
#2

mysql_function_query -> you need to use threaded function, you can't do store_result here, as it doesn't have it in that moment
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)