SA-MP Forums Archive
Help with dcmd and 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: Help with dcmd and sscanf (/showthread.php?tid=91194)



Help with dcmd and sscanf - Outbreak - 13.08.2009

Since i've been having CPU usage problems with my gamemode. I'm re-writing a lot of it. i've removed lots of useless pieces of code, i probably wrote without even thinking.

Anyway im trying to re-write the commands using dcmd and sscanf.

This is an example command i've done, but its sending the message to ID 0 and not the intended id.

pawn Код:
dcmd_caps(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 1 && !PlayerTempMod[playerid] && !PlayerTempAdmin[playerid] && !IsPlayerAdmin(playerid)) return DenyMessage(playerid, 1);

    new giveplayerid;
    if(sscanf(params, "u", giveplayerid)) SendClientMessage(playerid, COLOR_WHITE, "USAGE: /caps [playerid]");
  else if(giveplayerid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_RED, "Invalid Player ID.");
  else
  {
    SendClientMessage(giveplayerid, COLOR_YELLOW, "Please DO NOT use CAPs on this server...Thank You!");
        PlayerPlaySound(giveplayerid, 1147, 0,0,0);
        SendClientMessage(playerid, COLOR_PINK, "Message Sent!");
    }
  return 1;
}



Re: Help with dcmd and sscanf - ruarai - 13.08.2009

Weird...
Try:
pawn Код:
dcmd_caps(playerid, params[])
{

new giveplayerid;
if(sscanf(params, "u", giveplayerid)) SendClientMessage(playerid, COLOR_WHITE, "USAGE: /caps [playerid]");
if(PlayerInfo[playerid][pAdmin] < 1 && !PlayerTempMod[playerid] && !PlayerTempAdmin[playerid] && !IsPlayerAdmin(playerid)) return DenyMessage(playerid, 1);

  else if(giveplayerid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_RED, "Invalid Player ID.");
  else
  {
  SendClientMessage(giveplayerid, COLOR_YELLOW, "Please DO NOT use CAPs on this server...Thank You!");
PlayerPlaySound(giveplayerid, 1147, 0,0,0);
SendClientMessage(playerid, COLOR_PINK, "Message Sent!");
}
  return 1;
}



Re: Help with dcmd and sscanf - Andom - 13.08.2009

how did you defined dcmd(caps...... ?


Re: Help with dcmd and sscanf - Outbreak - 13.08.2009

under OnPlayerCommandText

dcmd(caps,4,cmdtext);

Exactly like it shows on the wiki about dcmd and sscanf


Edit: Just tried using "i" instead of "u" and it works fine. Not sure why it says to use "u" on the examples but it didnt work with that for me.