MySQL [Offline Kick]
#1

Hi, just have a trouble with a code... So my mod is MySQL... And i need a code ore ir simple command... ZCMD will be better... okay /fkick [player] And i need a code, to kick a player in offline mode... Imagine You're a faction leader, and you need to kick some one, but hes offlince, /fkick [player] boom and hes kicked...

Thanks
Reply
#2

pawn Код:
CMD:fkick(playerid,params[])
{
        new name[128];
        if (sscanf(params, "s",name))
        {
            SendClientMessage(playerid,WHITE,"* Usage /fkick [Name]");
            return 1;
        }
        new query[256];
        format(query,sizeof(query),"SELECT `Lead` FROM `Account` WHERE `Name`='%s' LIMIT 1",name);
        mysql_query(query);
        mysql_store_result();
        if(!mysql_num_rows()){ SendClientMessage(playerid, RED," * There's no such player!!"); mysql_free_result(); return 1;}
        if(mysql_fetch_int() == 0) { SendClientMessage(playerid, RED," * This player is not a leader!!"); mysql_free_result(); return 1; }
        mysql_free_result();
        format(query,sizeof(query),"UPDATE `Account` SET `Lead`=0 WHERE `Name`='%s' LIMIT 1",name);
        mysql_query(query);

        SendClientMessage(playerid, 0xD9E916FF, "* Success.");
        return 1;
}
This is what i use
Don't forget to change the query's to fit your database.
Reply
#3

pawn Код:
new Query[128];
format(Query, sizeof(Query), "DELETE FROM factions WHERE username = '%s' AND faction = %d;", Usernamehere, Faction id here);
mysql_query(Query);
Do not forget to check if the user actually exists.
Reply
#4

Okay thanks to wups, and cameltoe
Reply
#5

Okay now hes saying "There's no such player"
any help
and i got this

"[18:44:36] sscanf warning: Strings without a length are deprecated, please add a destination size."
Reply
#6

replace
if (sscanf(params, "s",name))
with
if (sscanf(params, "s[128]",name))
Reply
#7

how to make this not MySql ??
Reply
#8

Use the same method as Wups showed you, read the file with name, check if faction inside file = desired faction, if equals set faction inside file to -1 or so.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)