SA-MP Forums Archive
Problem with zcmd - 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)
+--- Thread: Problem with zcmd (/showthread.php?tid=417308)



Problem with zcmd - Mystique - 20.02.2013

Hello, as I've started scripting again I have had a few problems but I need to know what's causing and how I fix this. When I use the command /kick a message pops up in the server log saying: "sscanf warning: Strings without a length are deprecated, please add a destination size."



This is the code:

Код:
CMD:kick(playerid, params[])
{
       new id, reason[128], string[128], playername[MAX_PLAYER_NAME], playid[MAX_PLAYER_NAME];

       if(sscanf(params, "us", id, reason)){SendClientMessage(playerid, COLOR_RED, "Correct usage: /kick [playerid] [Reason]");}
	   else if(!IsPlayerConnected(id)){SendClientMessage(playerid, COLOR_RED, "The selected player is not connected.");}
	   else if(PlayerInfo[id][pAdmin] > 0) {SendClientMessage(playerid, COLOR_RED, "The selected player is an admin.");}
       else{
	   GetPlayerName(id, playid, sizeof(playid));
       GetPlayerName(playerid, playername, sizeof(playername));
	   format(string, sizeof(string),"[SERVER] %s has been kicked by %s. [Reason]: %s", playid, playername, reason[127]);
	   SendClientMessageToAll(COLOR_WHITE, string);
	   Kick(id);
	   }
	   return 1;
	   }



Re: Problem with zcmd - JamesS - 20.02.2013

Person under me was right, totally overlooked that.


Re: Problem with zcmd - ryansheilds - 20.02.2013

You didn't input the string size on the sscanf line. Add [128] after the s:
pawn Код:
if(sscanf(params, "us[128]", id, reason))



Re: Problem with zcmd - batonsa - 20.02.2013

I experienced this problem too until i went back to older sscanf version. Probably something to do with the new include compability with the old script, something like MySQL R7 doesn't support threaded queries no more.


Either you just fix some lines so they are compatible with the new include or you go back on the old one.


Re: Problem with zcmd - Mystique - 20.02.2013

Oh and one more question, why is it that my strcmp commands are not working anymore when I added zcmd? Do I have to change them to zcmd or is there a way to keep them as they am?


Re: Problem with zcmd - batonsa - 20.02.2013

strcmp and zcmd should function together, at least they do in my script.


Re: Problem with zcmd - ryansheilds - 20.02.2013

I believe you can't mix them together, you'll have to use one or the other. I recommend converting all strcmp commands to ZCMD.

OnPlayerCommandText isn't called when using ZCMD.


Re: Problem with zcmd - DaRk_RaiN - 20.02.2013

pawn Код:
CMD:kick(playerid, params[])
{
       new id, reason[128], string[128], playername[MAX_PLAYER_NAME], playid[MAX_PLAYER_NAME];

       if(sscanf(params, "us[127]", id, reason)){SendClientMessage(playerid, COLOR_RED, "Correct usage: /kick [playerid] [Reason]");}
       else if(!IsPlayerConnected(id)){SendClientMessage(playerid, COLOR_RED, "The selected player is not connected.");}
       else if(PlayerInfo[id][pAdmin] > 0) {SendClientMessage(playerid, COLOR_RED, "The selected player is an admin.");}
       else{
       GetPlayerName(id, playid, sizeof(playid));
       GetPlayerName(playerid, playername, sizeof(playername));
       format(string, sizeof(string),"[SERVER] %s has been kicked by %s. [Reason]: %s", playid, playername, reason[127]);
       SendClientMessageToAll(COLOR_WHITE, string);
       Kick(id);
       }
       return 1;
       }
Note:
In the last samp update, the messages before kick will not get sent to the player, so you'd have to do a costume one
For more info click here