Problem with my /die command
#1

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

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

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)