Command problem?
#1

i get errors on everything in my script when i put this in:
Код:
dcmd_fightstyle(playerid,params[])
{
	if(!strlen(params)) return SendClientMessage(playerid, red, "Example: /fightstyle [4 - 26]");
	new var = strval(params), string[128];
	for(new i = 0; i < MAX_PLAYERS; i++) {
	if(IsPlayerConnected(i)) {
	SetPlayerFightingStyle(i, var);
	return 1;

}
Reply
#2

use this
pawn Код:
if (!strcmp("/fightstyle 1", cmdtext))
  {
  SetPlayerFightingStyle(playerid, FIGHT_STYLE_NORMAL);
    SendClientMessage(playerid, 0xFFFFFFFF, "Fighting Style Change to Normal");
    return 1;
  }
 
  if (!strcmp("/fightstyle 2", cmdtext))
  {
  SetPlayerFightingStyle(playerid, FIGHT_STYLE_BOXING);
    SendClientMessage(playerid, 0xFFFFFFFF, "Fighting Style Change to Boxing");
    return 1;
  }
 
  if (!strcmp("/fightstyle 3", cmdtext))
  {
  SetPlayerFightingStyle(playerid, FIGHT_STYLE_KUNGFU);
    SendClientMessage(playerid, 0xFFFFFFFF, "Fighting Style Change to Kung Fu");
    return 1;
  }
people can crash your server with the command you posted
Reply
#3

They can not as the strval bug is fixed.
Reply
#4

no lol thats to much and i use dcmd
Reply
#5

Brackets.
Код:
dcmd_fightstyle(playerid,params[])
{
 if(!params[0]) return SendClientMessage(playerid, red, "Example: /fightstyle [4 - 26]");

 new fightstyle = strval(params);

 for(new i = 0; i < MAX_PLAYERS; i++)
 {
  if(IsPlayerConnected(i))
  {
   SetPlayerFightingStyle(i, fightstyle);
  }
 }

 return 1;
}
Reply
#6

pawn Код:
dcmd_fightstyle(playerid,params[])
{
    if(!strlen(params)) return SendClientMessage(playerid, /*red*/ 0xFF0000FF, "Example: /fightstyle [4, 5, 6, 7]");
    new var = strval(params);
    for(new i = 0; i < GetMaxPlayers(); i++)
    {
      if(IsPlayerConnected(i))
      {
            switch(var)
            {
            case 4, 5, 6, 7: SetPlayerFightingStyle(i, var);
          default:
                {
                    SendClientMessage(playerid, 0xFF0000FF, "Invalid fight style.");
                    break;
                }
            }
        }
    }
    return 1;
}
Reply
#7

Killerkid, like this it would be better.

pawn Код:
dcmd_fightstyle(playerid,params[])
{
 if(!params[0]) return SendClientMessage(playerid, /*red*/ 0xFF0000FF, "Example: /fightstyle [4, 5, 6, 7]");
 
 new var = strval(params);
 
 switch(var)
 {
  case 4, 5, 6, 7:
  {
   for(new i = 0; i < MAX_PLAYERS; i++)
   {
    if(IsPlayerConnected(i))
    {
     SetPlayerFightingStyle(i, var);
    }
   }
  }
 
  default:
  {
   SendClientMessage(playerid, 0xFF0000FF, "Invalid fight style.");
   break;
  }
 }

 return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)