Unknown 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)
+--- Thread: Unknown Command (
/showthread.php?tid=443099)
Unknown Command -
Kudoz - 10.06.2013
When I type the command which is under here, it says: "Use /setplayertg [playerid/name]" , which it should say. So when I try to add an ID to that, for example my own, like /setplayertg 0 , it says unknown command.. How can I fix this?
Код:
if (strcmp(cmdtext, "/setplayertg", true ) == 0)
{
new tmp[256];
tmp = strtok(cmdtext, idx);
new otherplayerid;
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Use /setplayertg [playerid/name]");
else if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, COLOR_LIGHTRED, "This player is not connected");
else
{
SendClientMessage(otherplayerid,COLOR_LIGHTRED,"You've been set to [Team 2] by an [Admin].");
setTG[otherplayerid] = 1;
}
return 1;
}
AW: Unknown Command -
Blackazur - 10.06.2013
Код:
if (strcmp(cmdtext, "/setplayertg", true ) == 0)
{
new tmp[256];
tmp = strtok(cmdtext, idx);
new otherplayerid;
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Use /setplayertg [playerid/name]");
else if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, COLOR_LIGHTRED, "This player is not connected");
SendClientMessage(otherplayerid,COLOR_LIGHTRED,"You've been set to [Team 2] by an [Admin].");
setTG[otherplayerid] = 1;
return 1;
}
maybe so, but i dont know.
Re: Unknown Command -
Kudoz - 10.06.2013
Still the same problem. "Unknown Command"
Re: Unknown Command -
IceBilizard - 10.06.2013
pawn Код:
if(!strcmp(cmd, "/setplayertg", true))
{
new tmp[256];
tmp = strtok(cmdtext, idx);
new otherplayerid;
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Use /setplayertg [playerid/name]");
else if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, COLOR_LIGHTRED, "This player is not connected");
SendClientMessage(otherplayerid,COLOR_LIGHTRED,"You've been set to [Team 2] by an [Admin].");
setTG[otherplayerid] = 1;
return 1;
}
Re: Unknown Command -
Kudoz - 10.06.2013
Thanks man! It works great!
Re: Unknown Command -
IceBilizard - 10.06.2013
You welcome
Re: Unknown Command -
Kudoz - 10.06.2013
oooh, one thing.. It only works for id 0.. even if I set /setplayertg 1 it sets id 0 tg..
Re: Unknown Command -
IceBilizard - 10.06.2013
try
Re: Unknown Command -
Kudoz - 10.06.2013
Errors..
Код:
C:\Users\daniel\Desktop\FOLDERS\0.3x\2013 scripts\driftrevolution.pwn(1608) : error 001: expected token: ";", but found "("
C:\Users\daniel\Desktop\FOLDERS\0.3x\2013 scripts\driftrevolution.pwn(1608) : warning 215: expression has no effect
Re: Unknown Command -
IceBilizard - 10.06.2013
pawn Код:
if(!strcmp(cmd, "/setplayertg", true))
{
new tmp[256];
tmp = strtok(cmdtext, idx);
new otherplayerid = ReturnUser(tmp);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Use /setplayertg [playerid/name]");
else if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, COLOR_LIGHTRED, "This player is not connected");
SendClientMessage(otherplayerid,COLOR_LIGHTRED,"You've been set to [Team 2] by an [Admin].");
setTG[otherplayerid] = 1;
return 1;
}
pawn Код:
ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
new pos = 0;
while (text[pos] < 0x21)
{
if (text[pos] == 0) return INVALID_PLAYER_ID;
pos++;
}
new userid = INVALID_PLAYER_ID;
if (IsNumeric(text[pos]))
{
userid = strval(text[pos]);
if (userid >=0 && userid < MAX_PLAYERS)
{
if(!IsPlayerConnected(userid))
userid = INVALID_PLAYER_ID;
else return userid;
}
}
new len = strlen(text[pos]);
new count = 0;
new pname[MAX_PLAYER_NAME];
for (new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
GetPlayerName(i, pname, sizeof (pname));
if (strcmp(pname, text[pos], true, len) == 0)
{
if (len == strlen(pname)) return i;
else
{
count++;
userid = i;
}
}
}
}
if (count != 1)
{
if (playerid != INVALID_PLAYER_ID)
{
if (count) SendClientMessage(playerid, red, "ERROR: There are multiple users, enter full playername.");
}
userid = INVALID_PLAYER_ID;
}
return userid;
}