Cant use the dcmd/sscanf - 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: Cant use the dcmd/sscanf (
/showthread.php?tid=242032)
Cant use the dcmd/sscanf -
bijoyekuza - 19.03.2011
Hey guys. I heard dcmd/sscanf is aswome .
So Im starting to learn that...
I tried to make the command kick
like this
I defined
Код:
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
then there is the command
Код:
dcmd_kick(playerid, params[])
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
if(!IsPlayerAdmin(playerid)) return 0;
new targetid, reason[64], string[128];
if(sscanf(params, "uz", targetid, reason)) return SendClientMessage(playerid, COLOR_RED, "Usage: /kick [playerid/partofname] [reason]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Player not connected or is yourself!");
format(string, sizeof(string), "%s has been kicked by Rcon Admin (Reason: %s)",pName, reason);
SendClientMessageToAll(COLOR_RED, string); // The yellow define will be up!
Kick(targetid);
}
not I got the errors
Код:
(1285) : error 017: undefined symbol "dcmd_kick"
(1287) : error 017: undefined symbol "dcmd_kick"
(1293) : error 017: undefined symbol "params"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
3 Errors.
Re: Cant use the dcmd/sscanf -
iJumbo - 19.03.2011
put under OnPlayerCommandText the rispective command like
4 mean the length of command
Re: Cant use the dcmd/sscanf -
Biesmen - 19.03.2011
I can see a couple of problems.
First of all, if you're using SSCANF2, it should be
pawn Код:
if(sscanf(params, "us[64]", targetid, reason)) [...]
If you're using SSCANF 1, it should be
pawn Код:
if(sscanf(params, "us", targetid, reason)) [...]
But I highly recommend you to use SSCANF2.
Let's try this:
At OnPlayerCommandText:
Somewhere in your script:
pawn Код:
dcmd_kick(playerid, params[])
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
if(!IsPlayerAdmin(playerid)) return 0;
new targetid, reason[64], string[128];
if(sscanf(params, "us[64]", targetid, reason)) return SendClientMessage(playerid, COLOR_RED, "Usage: /kick [playerid/partofname] [reason]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Player not connected or is yourself!");
format(string, sizeof(string), "%s has been kicked by Rcon Admin (Reason: %s)",pName, reason);
SendClientMessageToAll(COLOR_RED, string); // The yellow define will be up!
Kick(targetid);
}
If it still doesn't work, try to define DCMD again, but then this line:
pawn Код:
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
It is possible you made a typo at defining DCMD.
-
bijoyekuza - 19.03.2011
Do i have to include sscanf ? or just #define it in my scirpt?
Re: Cant use the dcmd/sscanf -
Biesmen - 19.03.2011
Yes,
#include <SSCANF2> on the top of your script, below
#include <a_samp>.