SA-MP Forums Archive
arrest system - 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: arrest system (/showthread.php?tid=329340)



arrest system - STONEGOLD - 28.03.2012

help me for /ar system and i want removed /ar [id] system only /ar and mouse middle btton system



Код:
	if(strcmp(cmd, "/arrest", true) == 0 || strcmp(cmd, "/ar", true) == 0)
	{
	new string[250];
    if(IsSpawned[playerid] == 0)
	{
	SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command");
    return 1;
    }
    if(gTeam[playerid] != COP && gTeam[playerid] != SWAT && gTeam[playerid] != ARMY && gTeam[playerid] != FBI)
	{
    SendClientMessage(playerid,COLOR_ERROR,"You are not a Law Enforcement officer ");
    return 1;
    }
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
	{
    SendClientMessage(playerid, COLOR_ERROR, "USAGE: /ar (id)");
    return 1;
    }
    giveplayerid = strval(tmp);
    if(!IsNumeric(tmp))
	{
    SendClientMessage(playerid, COLOR_ERROR, "USAGE: /ar (id) ID Must be a number");
    return 1;
    }
    if(!IsPlayerConnected(giveplayerid))
	{
    format(string, sizeof(string), "ID (%d) is not an active player", giveplayerid);
    SendClientMessage(playerid, COLOR_ERROR, string);
    return 1;
    }



and ticket system too

removed /tk id only /tk

Код:
if(strcmp(cmd, "/ticket", true) == 0 || strcmp(cmd, "/tk", true) == 0)
    {
    new string[128];
    if(IsSpawned[playerid] == 0)
	{
	SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command");
    return 1;
    }
    if(gTeam[playerid] != COP && gTeam[playerid] != SWAT && gTeam[playerid] != ARMY && gTeam[playerid] != FBI)
	{
    SendClientMessage(playerid,COLOR_ERROR,"You are not Law Enforcement");
    return 1;
    }
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)) {
    SendClientMessage(playerid, COLOR_ERROR, "USAGE: /tk (id)");
    return 1;
    }
    if(!IsNumeric(tmp))
	{
    SendClientMessage(playerid, COLOR_ERROR, "USAGE: /tk (id) ID Must be a number");
    return 1;
    }



Re: arrest system - jimis - 28.03.2012

yea i need help with this too...


Re: arrest system - SpiritEvil - 28.03.2012

I hope this helps:

pawn Код:
if(strcmp(cmd, "/arrest", true) == 0 || strcmp(cmd, "/ar", true) == 0)
{
    new string[250], giveplayerid;
    giveplayerid = GetClosestPlayerToPlayer(playerid);
    if(IsSpawned[playerid] == 0)
    {
        SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command");
        return 1;
    }
    if(gTeam[playerid] != COP && gTeam[playerid] != SWAT && gTeam[playerid] != ARMY && gTeam[playerid] != FBI)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You are not a Law Enforcement officer ");
        return 1;
    }
    if(!IsPlayerConnected(giveplayerid))
    {
        format(string, sizeof(string), "ID (%d) is not an active player", giveplayerid);
        SendClientMessage(playerid, COLOR_ERROR, string);
        return 1;
    }
    //perform the arrest on player 'giveplayerid'
    return 1;
}

if(strcmp(cmd, "/ticket", true) == 0 || strcmp(cmd, "/tk", true) == 0)
{
    new string[128], giveplayerid;
    giveplayerid = GetClosestPlayerToPlayer(playerid);
    if(IsSpawned[playerid] == 0)
    {
        SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command");
        return 1;
    }
    if(gTeam[playerid] != COP && gTeam[playerid] != SWAT && gTeam[playerid] != ARMY && gTeam[playerid] != FBI)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You are not Law Enforcement");
        return 1;
    }
    //Ticket the player with id "giveplayerid"
    return 1;
}

stock GetClosestPlayerToPlayer(playerid) //NOT BY ME! credits to the player who made this
{
    new Float:dist = 100.0;
    new targetid = INVALID_PLAYER_ID;
    new Float:x1,Float:y1,Float:z1;
    new Float:x2,Float:y2,Float:z2;
    new Float:tmpdis;
    GetPlayerPos(playerid,x1,y1,z1);
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if(i == playerid) continue;
        GetPlayerPos(i,x2,y2,z2);
        tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
        if(tmpdis < dist)
        {
            dist = tmpdis;
            targetid = i;
        }
    }
    return targetid;
}



Re: arrest system - jimis - 28.03.2012

I tried it too and i have this errors


C:\Users\Дзмзфсзт\Desktop\server4\gamemodes\newtes t.pwn(2532) : error 017: undefined symbol "cmd"
C:\Users\Дзмзфсзт\Desktop\server4\gamemodes\newtes t.pwn(2535) : error 017: undefined symbol "GetClosestPlayerToPlayer"
C:\Users\Дзмзфсзт\Desktop\server4\gamemodes\newtes t.pwn(2541) : warning 225: unreachable code


Re: arrest system - SpiritEvil - 28.03.2012

The commands should go under OnPlayerCommandText while the stock should be anywhere outside any function (usually at the end of the script). Anyway the commands are not complete. You have to perform the action on the comments I've added for the specified player.