SA-MP Forums Archive
MySQL [Offline Kick] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: MySQL [Offline Kick] (/showthread.php?tid=273379)



MySQL [Offline Kick] - No Fear - 01.08.2011

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


Re: MySQL [Offline Kick] - wups - 01.08.2011

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.


Re: MySQL [Offline Kick] - Cameltoe - 01.08.2011

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.


Re: MySQL [Offline Kick] - No Fear - 01.08.2011

Okay thanks to wups, and cameltoe


Re: MySQL [Offline Kick] - No Fear - 01.08.2011

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."


Re: MySQL [Offline Kick] - wups - 01.08.2011

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


Re: MySQL [Offline Kick] - Speed - 01.08.2011

how to make this not MySql ??


Re: MySQL [Offline Kick] - Cameltoe - 01.08.2011

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.