Command problem? - 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: Command problem? (
/showthread.php?tid=95677)
Command problem? -
[mad]MLK - 04.09.2009
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;
}
Re: Command problem? -
V1ceC1ty - 04.09.2009
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
Re: Command problem? -
dugi - 04.09.2009
They can not as the strval bug is fixed.
Re: Command problem? -
[mad]MLK - 04.09.2009
no lol thats to much and i use dcmd
Re: Command problem? -
Balon - 04.09.2009
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;
}
Re: Command problem? -
Killerkid - 04.09.2009
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;
}
Re: Command problem? -
Balon - 04.09.2009
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;
}