SA-MP Forums Archive
Im stumped, can someone please tell me whats causing it.. - 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: Im stumped, can someone please tell me whats causing it.. (/showthread.php?tid=144191)



Im stumped, can someone please tell me whats causing it.. - chaosnz - 26.04.2010

Heres the code.
Quote:

if(strcmp(cmd, "/detain", true)==0)
{
if (gTeam[playerid] == TEAM_COP)
{
tmp = strtok(cmdtext, idx);

if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /detain [ID]");
return 1;
}
new pid = strval(tmp);
if(GetDistanceBetweenPlayers(playerid,pid) > 5) return SendClientMessage(playerid, COLOR_LIME, "You need to be with in 5 feet of your suspect to detain.");
if (IsPlayerConnected(pid))
{
new vehicleid;
vehicleid = GetPlayerVehicleID(playerid);
PutPlayerInVehicle(pid,vehicleid,3);
TogglePlayerControllable(playerid,0);
SendClientMessage(pid, COLOR_WHITE, "You have been detained by a Police Officer");
}
}
else return SendClientMessage(playerid, COLOR_LIME, "Only Police Officers can use this command.");
return 1;
}
if(strcmp(cmd, "/kidnap", true)==0)
{
if (gTeam[playerid] == TEAM_CRIMINAL)
{
tmp = strtok(cmdtext, idx);

if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /kidnap [ID]");
return 1;
}
new pid = strval(tmp);
if(GetDistanceBetweenPlayers(playerid,pid) > 5) return SendClientMessage(playerid, COLOR_LIME, "You need to be with in 5 feet of your target to kidnap");
if (IsPlayerConnected(pid))
{
new vehicleid;
vehicleid = GetPlayerVehicleID(playerid);
PutPlayerInVehicle(pid,vehicleid,3);
TogglePlayerControllable(playerid,0);
SendClientMessage(pid, COLOR_WHITE, "You have been kidnapped!");
}
}
else return SendClientMessage(playerid, COLOR_LIME, "Only Criminals can use this command.");
return 1;
}

Now what problem is that when i type /detain without an id, it displays the [else return SendClientMessage(playerid, COLOR_LIME, "Only Police Officers can use this command.");] line instead of the [SendClientMessage(playerid, COLOR_WHITE, "USAGE: /detain [ID]");] line. But other than that, the detain works. When i type /kidnap how ever, it shows the [else return SendClientMessage(playerid, COLOR_LIME, "Only Police Officers can use this command.");] line, not the [else return SendClientMessage(playerid, COLOR_LIME, "Only Criminals can use this command.");] line.

What am i missing to get this to work properly?