SA-MP Forums Archive
Problem with my /die command - 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: Problem with my /die command (/showthread.php?tid=208944)



Problem with my /die command - Jay. - 09.01.2011

Hey, I started scripted a while ago now and have forgot a few things... so I might fail a bit, like I did here.
I created a /die [reason] command, but the problem is, it doesn't show the reason. I'm using sscanf and dcmd.
pawn Код:
dcmd_die(playerid,params[])
{

   new string[128],reason[25],name[25];
   if(sscanf(params,"u",playerid,reason)) SendClientMessage(playerid,red,"Usage: /die [reason]");
   else
   {
       GetPlayerName(playerid,name,sizeof(name));
       format(string,sizeof(string),"%s killed himself reason: %s",name,reason);
       SendClientMessageToAll(white,string);
           SetPlayerHealth(playerid,0);
   }
   return 1;

}
If you know the problem, please reply thx


Re: Problem with my /die command - JaTochNietDan - 09.01.2011

No need for sscanf in this situation. Although your sscanf syntax is wrong anyway, it should be:

pawn Код:
if(sscanf(params,"s",reason))
But really you don't need it here, just this:

pawn Код:
dcmd_die(playerid,params[])
{
   new string[128],name[25];
   if(!strlen(params)) SendClientMessage(playerid,red,"Usage: /die [reason]");
   else
   {
       GetPlayerName(playerid,name,sizeof(name));
       format(string,sizeof(string),"%s killed himself reason: %s",name,params);
       SendClientMessageToAll(white,string);
       SetPlayerHealth(playerid,0);
   }
   return 1;
}



Re: Problem with my /die command - Jay. - 09.01.2011

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
No need for sscanf in this situation. Although your sscanf syntax is wrong anyway, it should be:

pawn Код:
if(sscanf(params,"s",reason))
But really you don't need it here, just this:

pawn Код:
dcmd_die(playerid,params[])
{
   new string[128],name[25];
   if(!strlen(params)) SendClientMessage(playerid,red,"Usage: /die [reason]");
   else
   {
       GetPlayerName(playerid,name,sizeof(name));
       format(string,sizeof(string),"%s killed himself reason: %s",name,params);
       SendClientMessageToAll(white,string);
       SetPlayerHealth(playerid,0);
   }
   return 1;
}
Thanks