Handcuff 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
  • Guten Tag,
    Ich habe mal wieder, wie kann es auch anders sein, ein Problem mit einer funktion bei mir im Script.
    Und zwar handelt es sich dieses mal um mein /cuff command.
    Ich kann ihn cuffen und auch wieder uncuffen lassen, das Problem ist allerdings das die Animation irgendwie nicht gemacht wir...



    ocmd:cuff(playerid, params[])
    {
    new targetid;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "/cuff [Player ID]");
    if(IsPlayerConnected(targetid))
    {
    if(pInfo[playerid][Fraktion] == 1)
    {
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if(IsPlayerInRangeOfPoint(targetid, 5.0, x, y, z))
    {
    new str[512];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    new target[MAX_PLAYER_NAME];
    GetPlayerName(targetid, target, sizeof(target));
    format(str, sizeof(str), "Du hast %s Handschellen angelegt!",target);
    SendClientMessage(playerid, dunkelgrün, str);
    format(str, sizeof(str), "Dir wurden Handschellen von %s angelegt!",name);
    SendClientMessage(targetid, dunkelrot, str);
    SetPlayerAttachedObject(playerid, 6, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CUFFED);
    TogglePlayerControllable(playerid,false);
    TogglePlayerControllable(playerid,true);
    return 1;
    }
    else
    {
    SendClientMessage(playerid,dunkelrot,"Du bist zu weit weg!");
    }
    }
    else
    {
    SendClientMessage(playerid,dunkelrot,"Du bist kein Polizist!");
    }
    }
    return 1;
    }


    Hilfe wäre wie immer supi :thumbup:

    Ich bin wieder da, MoFogga


    You're not completely useless. You can always serve as a bad example!

  • so sollte es gehen.



    ocmd:cuff(playerid, params[])
    {
    new targetid, String[512], name[MAX_PLAYER_NAME], target[MAX_PLAYER_NAME], Float:x, Float:y, Float:z;

    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "/cuff [Player ID]");
    if(pInfo[playerid][Fraktion] != 1)return SendClientMessage(playerid,dunkelrot,"Du bist kein Polizist!");
    if(IsPlayerConnected(targetid))return SendClientMessage(playerid,dunkelrot,"Dieser Spieler ist nicht Online!");
    if(!IsPlayerInRangeOfPoint(targetid, 5.0, x, y, z))return SendClientMessage(playerid,dunkelrot,"Du bist zu weit weg!");


    GetPlayerPos(playerid, x, y, z);
    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerName(targetid, target, sizeof(target));

    format(String, sizeof(String), "Du hast %s Handschellen angelegt!", target);
    SendClientMessage(playerid, dunkelgrün, String);


    format(String, sizeof(String), "Dir wurden Handschellen von %s angelegt!", name);
    SendClientMessage(targetid, dunkelrot, String);

    SetPlayerAttachedObject(targetid, 6, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
    SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
    TogglePlayerControllable(targetid, 0);
    return 1;
    }

  • So, danke @ZeusLukas , gibt keine errors etc. allerdings habe ich nun versucht das gleiche mit dem uncuff befehl zu machen, und er gibt undefined symbol "x" aus.
    Vor meiner Umstellung hat es perfekt geklappt, die handschellen wurden entfernt etc :)


    ocmd:uncuff(playerid, params[])
    {
    new targetid;//this defines the id of the player you want to cuff((playerid id your id and the target id that I defined it the id of the player you want to cuff))
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "/uncuff [Player ID]");
    if(pInfo[playerid][Fraktion] != 1)return SendClientMessage(playerid,dunkelrot,"Du bist kein Polizist!");
    if(IsPlayerConnected(targetid))return SendClientMessage(playerid,dunkelrot,"Dieser Spieler ist nicht Online!");
    if(!IsPlayerInRangeOfPoint(targetid, 5.0, x, y, z))return SendClientMessage(playerid,dunkelrot,"Du bist zu weit weg!");
    new Float:x, Float:y, Float:z;//these are the defines of your x,y and z position.
    GetPlayerPos(playerid, x, y, z);//this will store your position to be used in the following codes.((this stores the your x,y, and z position in to the variables we created.))
    if(!SetPlayerAttachedObject(targetid, 6, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977,-81.700035, 0.891999, 1.000000, 1.168000))return SendClientMessage(playerid,-1,"ERROR: The player is not cuffed!");//this will check that if the player is not cuffed and you are trying to apply this cmd,this will send him a error message.
    SetPlayerSpecialAction(targetid,SPECIAL_ACTION_NONE);//this will remove the players cuffs and his arms will go normal.
    new str[512];//this it the define for the string you will format further.((str means string.You can also change it to string but this seems to be easy.))
    new name[MAX_PLAYER_NAME];//this is the variable you created to store the your name.
    GetPlayerName(playerid, name, sizeof(name));//this will get your name and store it in the variable you defines as name.
    new target[MAX_PLAYER_NAME];//this is the variable you created to store the name of the player you want to cuff.
    GetPlayerName(targetid, target, sizeof(target));//this will get the name of the person you want to cuff and will store it into a variable we defined as target.
    format(str, sizeof(str), "Du hast %s die Handschellen abgenommen!",target);//explained at the end of the tutorial.
    SendClientMessage(playerid, dunkelgrün, str);//will send the formated message to you that you created above.
    format(str, sizeof(str), "Die Handschellen wurden dir von %s abgenommen!",name);//explained bellow.
    SendClientMessage(targetid, dunkelrot, str);//will send the formated message to the player you want to cuff that you created above.
    if(IsPlayerAttachedObjectSlotUsed(playerid, 6)) RemovePlayerAttachedObject(playerid, 6);
    TogglePlayerControllable(targetid, 0);
    TogglePlayerControllable(targetid, 1);
    return 1;
    }

    Ich bin wieder da, MoFogga


    You're not completely useless. You can always serve as a bad example!

  • im Kopf vom Befehl solltest du immer die Variablen definieren



    ocmd:uncuff(playerid, params[])
    {
    new targetid, Float:x, Float:y, Float:z, str[512], name[MAX_PLAYER_NAME], target[MAX_PLAYER_NAME];


    GetPlayerPos(playerid, x, y, z);

    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "/uncuff [Player ID]");
    if(pInfo[playerid][Fraktion] != 1)return SendClientMessage(playerid,dunkelrot,"Du bist kein Polizist!");
    if(IsPlayerConnected(targetid))return SendClientMessage(playerid,dunkelrot,"Dieser Spieler ist nicht Online!");
    if(!IsPlayerInRangeOfPoint(targetid, 5.0, x, y, z))return SendClientMessage(playerid,dunkelrot,"Du bist zu weit weg!");
    if(!IsPlayerAttachedObjectSlotUsed(playerid, 6))return SendClientMessage(playerid,-1,"ERROR: Dieser Spieler ist nicht gefesselt!");


    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerName(targetid, target, sizeof(target));


    format(str, sizeof(str), "Du hast %s die Handschellen abgenommen!", target);
    SendClientMessage(playerid, dunkelgrün, str);


    format(str, sizeof(str), "Die Handschellen wurden dir von %s abgenommen!", name);
    SendClientMessage(targetid, dunkelrot, str);


    TogglePlayerControllable(targetid, 1);
    RemovePlayerAttachedObject(targetid, 6);
    SetPlayerSpecialAction(targetid, SPECIAL_ACTION_NONE);
    return 1;
    }


    //Edit

    Einmal editiert, zuletzt von Lukaz ()

  • Ehm, der sagt mir nun, nach 2Verbesserungen an deinen Codezeilen, Du bist zu weit weg, obwohl ich das ja selber bin :/ @ZeusLukas

    Ich bin wieder da, MoFogga


    You're not completely useless. You can always serve as a bad example!