/arrest Problem

Wichtiger Hinweis: Bitte ändert nicht manuell die Schriftfarbe auf schwarz sondern belasst es bei der Standardeinstellung. Somit tragt ihr dazu bei dass euer Text auch bei Verwendung unseren dunklen Forenstils noch lesbar ist!

Tipp: Ihr wollt längere Codeausschnitte oder Logfiles bereitstellen? Benutzt unseren eigenen PasteBin-Dienst Link
  • Wenn ich /arrest ID mache dann steht da
    Du kannst keinen Beamten einsperren!
    Aber der ist kein Cop.
    Hier ist der Pawn Code:



    if(strcmp(cmd, "/arrest", true) == 0)
    {
    if(IsPlayerConnected(playerid))
    {
    if(gTeam[playerid] == 2 || IsACop(playerid) || PlayerInfo[playerid][pMember] == 12 || PlayerInfo[playerid][pLeader] == 12 || PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pLeader] == 2 || PlayerInfo[playerid][pMember] == 3 || PlayerInfo[playerid][pLeader] == 3)
    {
    if(OnDuty[playerid] != 1 && PlayerInfo[playerid][pMember] == 1)
    {
    SendClientMessage(playerid, COLOR_GREY, " Du bist nicht im Dienst!");
    return 1;
    }
    if(IsPlayerInRangeOfPoint(playerid,6.0, 1564.5873,-1694.4680,5.8906) || IsPlayerInRangeOfPoint(playerid,3.0,268.5958,85.1651,1001.0391) || IsPlayerInRangeOfPoint(playerid,3.0,-1702.6952,1017.9680,17.5859))
    {// Jail spot
    new suspect = GetClosestPlayer(playerid);
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
    SendClientMessage(playerid, COLOR_GRAD2, "Benutze: /arrest (ID / Name)");
    return 1;
    }
    if(IsACop(suspect))
    {
    SendClientMessage(playerid, COLOR_GRAD2, " Du kannst keinen Beamten einsperren!");
    return 1;
    }
    if(IsPlayerConnected(suspect))
    {
    if(GetDistanceBetweenPlayers(playerid,suspect) < 5)
    {
    GetPlayerName(suspect, giveplayer, sizeof(giveplayer));
    GetPlayerName(playerid, sendername, sizeof(sendername));
    if(WantedLevel[suspect] < 1)
    {
    SendClientMessage(playerid, COLOR_GREY, " Der Spieler ist nicht gesucht!");
    return 1;
    }
    GivePlayerMoney(suspect,-WantedLevel[suspect]*750);
    GivePlayerMoney(playerid,WantedLevel[suspect]*750);
    PlayerInfo[playerid][pGehalt] += WantedLevel[suspect]*2000;
    ResetPlayerWeapons(suspect);
    if(PlayerInfo[playerid][pMember]==1||PlayerInfo[playerid][pLeader]==1)
    {
    format(string, sizeof(string), "INFO: Officer %s hat den Verbrecher %s eingesperrt", SpielerName(playerid), SpielerName(suspect));
    OOCNews(COLOR_RED, string);
    }
    else if(PlayerInfo[playerid][pMember]==2||PlayerInfo[playerid][pLeader]==2)
    {
    format(string, sizeof(string), "INFO: Agent %s hat den Verbrecher %s eingesperrt", SpielerName(playerid), SpielerName(suspect));
    OOCNews(COLOR_RED, string);
    }
    else if(PlayerInfo[playerid][pMember]==3||PlayerInfo[playerid][pLeader]==3)
    {
    format(string, sizeof(string), "INFO: Soldat %s hat den Verbrecher %s eingesperrt", SpielerName(playerid), SpielerName(suspect));
    OOCNews(COLOR_RED, string);
    }
    else if(PlayerInfo[playerid][pMember]==22||PlayerInfo[playerid][pLeader]==22)
    {
    format(string, sizeof(string), "INFO: SWAT Agent %s hat den Verbrecher %s eingesperrt", SpielerName(playerid), SpielerName(suspect));
    OOCNews(COLOR_RED, string);
    }
    if(LSPDZellen == 0)//zelle1
    {
    SetPlayerInterior(suspect, 6);
    UnFreezePlayer(suspect);
    PlayerCuffed[suspect] = 0;
    SetPlayerPos(suspect,264.0306,82.5047,1001.0391);
    LSPDZellen += 1;
    }
    if(LSPDZellen == 1)//zelle2
    {
    SetPlayerInterior(suspect, 6);
    UnFreezePlayer(suspect);
    PlayerCuffed[suspect] = 0;
    SetPlayerPos(suspect,263.5588,86.7332,1001.0391);
    LSPDZellen += 1;
    }
    if(LSPDZellen == 2)//zelle3
    {
    SetPlayerInterior(suspect, 6);
    UnFreezePlayer(suspect);
    PlayerCuffed[suspect] = 0;
    SetPlayerPos(suspect,263.5588,86.7332,1001.0391);
    LSPDZellen = 0;
    }
    PlayerInfo[suspect][pJailTime] = WantedLevel[suspect] * 240;
    new spr[100];
    format(spr,sizeof(spr),"Du wurdest für %d Minuten und einer Geldstrafe von %d$ eingesperrt",WantedLevel[suspect] * 4,WantedLevel[suspect] * 2000);
    SendClientMessage(playerid,COLOR_LIGHTBLUE,spr);
    PlayerInfo[suspect][pJailed] = 1;
    PlayerInfo[suspect][pArrested] += 1;
    SetPlayerInterior(suspect, 6);
    SetPlayerFree(suspect,playerid, "Verhaftet");
    WantedPoints[suspect] = 0;
    WantedLevel[suspect] = 0;
    SetPlayerWantedLevel(suspect,0);
    }//distance
    }
    }
    else
    {
    SendClientMessage(playerid, COLOR_GREY, " Niemand zum Verhaften in deiner Nähe.");
    return 1;
    }
    }
    else
    {
    SendClientMessage(playerid, COLOR_GREY, " Du bist kein Beamter !");
    return 1;
    }
    }//not connected
    return 1;
    }

  • Function IsACop(playerid)
    {
    if(IsPlayerConnected(playerid))
    {
    new leader = PlayerInfo[playerid][pLeader];
    new member = PlayerInfo[playerid][pMember];
    if(member==1 || member==2 || member==22 || member==3)
    {
    return 1;
    }
    else if(leader==1 || leader==2 || leader==22 || leader==3)
    {
    return 1;
    }
    }
    return 0;
    }

  • Sry dass es gso Lange gedauert hat^^
    Function GetClosestPlayer(p1)
    {
    new x,Float:dis,Float:dis2,player;
    player = -1;
    dis = 99999.99;
    for (x=0;x<MAX_PLAYERS;x++)
    {
    if(IsPlayerConnected(x))
    {
    if(x != p1)
    {
    dis2 = GetDistanceBetweenPlayers(x,p1);
    if(dis2 < dis && dis2 != -1.00)
    {
    dis = dis2;
    player = x;
    }
    }
    }
    }
    return player;