Problem with zcmd
#1

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;
	   }
Reply
#2

Person under me was right, totally overlooked that.
Reply
#3

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

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.
Reply
#5

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?
Reply
#6

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

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.
Reply
#8

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)