Hilfe! Camera geht nicht mit dem Spieler mit.

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
  • Hallo. Meine Camera geht nicht mit dem Spieler mit.


    Mein gesamter Code:


    #include <a_samp>
    #include <dini>
    #include <ocmd>


    #define BLAU 0x0087FFFF
    #define ROT 0xE10000FF


    #define DIALOG_TUTORIAL 1
    #define DIALOG_REGISTER 2
    #define DIALOG_LOGIN 3



    new bsnenter;
    new bsnexit;
    #define GELB 0xFFFF00AA
    new Schranke,IstSchrankeOben=0;



    main()
    {
    print("\n----------------------------------");
    print("Gestartet");
    print("----------------------------------\n");
    }



    public OnGameModeInit()
    {
    UsePlayerPedAnims();
    bsnexit=CreatePickup(1559,1,362.8524,-75.1179,1001.5078);
    bsnenter=CreatePickup(1559,1,1199.2235,-918.1543,43.1233);


    Create3DTextLabel("BSN\n Eingang",BLAU,1199.2235,-918.1543,43.1233,10,0);


    DisableInteriorEnterExits();
    SetGameModeText("Pixel:SAMP");
    AddPlayerClass(0,2047.4270,1336.5569,10.6719,188.9284,0,0,0,0,0,0); // position;


    SetVehicleNumberPlate(CreateVehicle(401,1227.1797,-914.0590,42.6812,99.6721,126,126,1),"Auto 1");
    AddStaticVehicle(409,1226.2432,-905.7473,42.6997,10.2423,151,151); // auto2
    AddStaticVehicle(481,1468.7216,-1726.4866,13.0557,4.1280,46,46); // f1
    AddStaticVehicle(481,1469.7393,-1726.6013,13.0402,3.3287,14,1); // f2
    AddStaticVehicle(481,1470.9053,-1726.2328,13.0498,6.2324,26,1); // f3
    Schranke = CreateObject(968,1544.7988,-1626.6984,13.3828,0,90, 278.74768066406); //Schranke Unten
    return 1;
    }


    public OnGameModeExit()
    {
    return 1;
    }


    public OnPlayerRequestClass(playerid, classid)
    {
    SetPlayerPos(playerid,2047.4270,1336.5569,10.6719);
    SetPlayerFacingAngle(playerid,188.9284);
    SetPlayerCameraPos(playerid,2047.6205,1333.3314,10.6719);
    SetPlayerCameraLookAt(playerid,2047.4270,1336.5569,10.6719);


    return 1;
    }


    public OnPlayerConnect(playerid)
    {
    new Spielerdatei[64];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(Spielerdatei,sizeof(Spielerdatei),"/Accounts/%s.txt",name);
    if(dini_Exists(Spielerdatei))
    {
    ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Dein Account wurde gefunden. Gib bitte das Passwort ein.","Login","Abbrechen");
    }
    else
    {
    ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Registrieren","Gib bitte das gewünschte Passwort ein:","Register","Abbrechen");
    }

    return 1;
    }


    public OnPlayerDisconnect(playerid, reason)
    {
    if(GetPVarInt(playerid,"loggedin")==1)
    {
    SpielerSpeichern(playerid);
    }
    return 1;
    }


    public OnPlayerSpawn(playerid)
    {
    new name[MAX_PLAYER_NAME];
    new wel[44];
    GetPlayerName(playerid, name, sizeof(name));
    format(wel,sizeof(wel),"Willkommen %s",name);
    GameTextForPlayer(playerid, wel, 3000, 1);
    return 1;
    }


    public OnPlayerDeath(playerid, killerid, reason)
    {
    return 1;
    }


    public OnVehicleSpawn(vehicleid)
    {
    return 1;
    }


    public OnVehicleDeath(vehicleid, killerid)
    {
    return 1;
    }


    public OnPlayerText(playerid, text[])
    {
    return 1;
    }


    ocmd:ad(playerid,params[])
    {
    new text[128],string[128];
    if(sscanf(params,"s",text))return SendClientMessage(playerid,BLAU,"/ad [Text]");
    format(string,sizeof(string),"----- Werbung -----\n: %s \n --------------",text);
    SendClientMessageToAll(ROT,string);
    return 1;
    }


    ocmd:setadmin(playerid,params[])
    {
    if(!isPlayerAnAdmin(playerid,5))return SendClientMessage(playerid,ROT,"Du bist kein Admin.");
    new pID, rank;
    if(sscanf(params,"ui",pID,rank))return SendClientMessage(playerid,ROT,"/setadmin [spieler] [level]");
    if(rank<1||rank>5)return SendClientMessage(playerid,ROT,"Bitte gültigen Rang angeben.");
    SetPVarInt(pID,"Adminlevel",rank);
    SpielerSpeichern(pID);
    SendClientMessageToAll(BLAU,"Es wurde jemand zu Admin gemacht.");
    return 1;
    }


    ocmd:ban(playerid,params[])
    {
    if(!isPlayerAnAdmin(playerid,2))return SendClientMessage(playerid,ROT,"Du bist kein Admin.");
    new pID, reason[128],string[128];
    if(sscanf(params,"us",pID,reason))return SendClientMessage(playerid,BLAU,"/ban [id] [grund]");
    format(string,sizeof(string),"AdmCmd: %s wurde von %s gebannt. Grund: %s",SpielerName(pID),SpielerName(playerid),reason);
    SendClientMessageToAll(ROT,string);
    SetPVarInt(pID,"Baned",1);
    Kick(pID);
    return 1;
    }


    ocmd:kick(playerid,params[])
    {
    if(!isPlayerAnAdmin(playerid,2))return SendClientMessage(playerid,ROT,"Du bist kein Admin.");
    new pID, reason[128],string[128];
    if(sscanf(params,"us",pID,reason))return SendClientMessage(playerid,BLAU,"/kick [id] [grund]");
    format(string,sizeof(string),"AdmCmd: %s wurde von %s gekickt. Grund: %s",SpielerName(pID),SpielerName(playerid),reason);
    SendClientMessageToAll(ROT,string);
    Kick(pID);
    return 1;
    }


    ocmd:money(playerid,params[])
    {
    new msg[128];
    if(!isPlayerAnAdmin(playerid,2))return SendClientMessage(playerid,ROT,"Du bist kein Admin.");
    new gm;
    if(sscanf(params,"i",gm))return SendClientMessage(playerid,BLAU,"/money [wert]");
    format(msg,sizeof(msg),"Du hast nun %s Dollar dazugekriegt.", gm);
    SendClientMessage(playerid,BLAU,msg);
    GivePlayerMoney(playerid,gm);
    return 1;
    }


    public OnPlayerCommandText(playerid, cmdtext[])
    {
    if(strcmp(cmdtext,"/bsn",true)==0)
    {
    if(isPlayerAnAdmin(playerid,3))
    {
    ShowPlayerDialog(playerid,DIALOG_TUTORIAL,DIALOG_STYLE_MSGBOX,"BSN","Möchten sie wirklich zum BSN?","JA","NEIN");
    return 1;
    }
    SendClientMessage(playerid,BLAU,"Du bist kein Admin.");
    return 1;
    }
    if(strcmp(cmdtext,"/kill",true)==0)
    {
    SetPlayerHealth(playerid,0);
    return 1;
    }
    if(strcmp(cmdtext,"/restart",true)==0)
    {
    if(isPlayerAnAdmin(playerid,5))
    {
    SendRconCommand("gmx");
    return 1;
    }
    SendClientMessage(playerid,BLAU,"Du bist kein Admin.");
    return 1;
    }
    if(strcmp(cmdtext,"/stats",true)==0)
    {
    new string[128];
    new fraktname[64];
    switch(GetPVarInt(playerid,"Fraktion"))
    {
    case 0:{fraktname="Keine";}
    case 1:{fraktname="Fraktname 1";}
    case 2:{fraktname="Fraktname 2";}
    case 3:{fraktname="Fraktname 3";}
    }
    //1 reihe
    format(string,sizeof(string),"[Name: %s] [Level: %i] [Adminlevel: %i] [Fraktion: %s]",SpielerName(playerid),GetPlayerScore(playerid),GetPVarInt(playerid,"Adminlevel"),fraktname);
    SendClientMessage(playerid,BLAU,string);
    //2 reihe
    return 1;
    }
    if(strcmp(cmdtext,"/nschild",true)==0)
    {
    if(IsPlayerInAnyVehicle(playerid))
    {
    new vehicleid;
    vehicleid=GetPlayerVehicleID(playerid);
    SetVehicleNumberPlate(vehicleid,"Test");
    SetVehicleToRespawn(vehicleid);
    PutPlayerInVehicle(playerid,vehicleid,0);
    }
    return 1;
    }
    if(strcmp(cmdtext,"/heli",true)==0)
    {
    if(isPlayerAnAdmin(playerid,5))
    {
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid,x,y,z);
    AddStaticVehicle(487,x,y,z,82.2873, 0, 1);
    return 1;
    }
    }
    if(!strcmp("/schranke", cmdtext, true))
    {
    if(IstSchrankeOben == 1)
    {
    SetObjectRot(Schranke, 0, 90, 278.74768066406);
    IstSchrankeOben = 0;
    }
    else if(IstSchrankeOben == 0)
    {
    SetObjectRot(Schranke, 0, 0, 279.5);
    IstSchrankeOben = 1;
    }
    return 1;
    }

    return 0;
    }


    public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
    {
    return 1;
    }


    public OnPlayerExitVehicle(playerid, vehicleid)
    {
    return 1;
    }


    public OnPlayerStateChange(playerid, newstate, oldstate)
    {
    return 1;
    }


    public OnPlayerEnterCheckpoint(playerid)
    {
    return 1;
    }


    public OnPlayerLeaveCheckpoint(playerid)
    {
    return 1;
    }


    public OnPlayerEnterRaceCheckpoint(playerid)
    {
    return 1;
    }


    public OnPlayerLeaveRaceCheckpoint(playerid)
    {
    return 1;
    }


    public OnRconCommand(cmd[])
    {
    return 1;
    }


    public OnPlayerRequestSpawn(playerid)
    {
    return 1;
    }


    public OnObjectMoved(objectid)
    {
    return 1;
    }


    public OnPlayerObjectMoved(playerid, objectid)
    {
    return 1;
    }


    public OnPlayerPickUpPickup(playerid, pickupid)
    {
    if(pickupid==bsnenter)
    {
    SetPlayerPos(playerid,375.962463,-65.816848,1001.507812);
    SetPlayerInterior(playerid,10);
    GameTextForPlayer(playerid,"~w~Du ~r~hast ~b~den ~n~~g~BSN betreten.",3000,3);
    }
    if(pickupid==bsnexit)
    {
    SetPlayerPos(playerid,1199.4618,-920.8215,43.1059);
    SetPlayerFacingAngle(playerid,185.7090);
    SetCameraBehindPlayer(playerid);
    SetPlayerInterior(playerid,0);
    }
    return 1;
    }


    public OnVehicleMod(playerid, vehicleid, componentid)
    {
    return 1;
    }


    public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
    {
    return 1;
    }


    public OnVehicleRespray(playerid, vehicleid, color1, color2)
    {
    return 1;
    }


    public OnPlayerSelectedMenuRow(playerid, row)
    {
    return 1;
    }


    public OnPlayerExitedMenu(playerid)
    {
    return 1;
    }


    public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
    {
    return 1;
    }


    public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
    {
    return 1;
    }


    public OnRconLoginAttempt(ip[], password[], success)
    {
    return 1;
    }


    public OnPlayerUpdate(playerid)
    {
    return 1;
    }


    public OnPlayerStreamIn(playerid, forplayerid)
    {
    return 1;
    }


    public OnPlayerStreamOut(playerid, forplayerid)
    {
    return 1;
    }


    public OnVehicleStreamIn(vehicleid, forplayerid)
    {
    return 1;
    }


    public OnVehicleStreamOut(vehicleid, forplayerid)
    {
    return 1;
    }


    public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
    {
    if(dialogid==DIALOG_LOGIN)
    {
    if(response==0)
    {
    SendClientMessage(playerid,BLAU,"Du hast den Vorgang abgebrochen.");
    Kick(playerid);
    return 1;
    }
    if(response==1)
    {
    if(!strlen(inputtext))
    {
    SendClientMessage(playerid,BLAU,"Das Passwort war nicht lang genug.");
    ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Dein Account wurde gefunden. Gib bitte das Passwort ein.","Login","Abbrechen");
    return 1;
    }
    else
    {
    Login(playerid,inputtext);
    SpawnPlayer(playerid);
    return 1;
    }
    }
    }
    if(dialogid==DIALOG_REGISTER)
    {
    if(response==0)
    {
    SendClientMessage(playerid,BLAU,"Du hast den Vorgang abgebrochen.");
    Kick(playerid);
    return 1;
    }
    if(response==1)
    {
    if(!strlen(inputtext))
    {
    SendClientMessage(playerid,BLAU,"Das Passwort war nicht lang genug.");
    ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Registrieren","Gib bitte das gewünschte Passwort ein:","Register","Abbrechen");
    return 1;
    }
    else
    {
    Register(playerid,inputtext);
    return 1;
    }
    }
    }
    if(dialogid==DIALOG_TUTORIAL)
    {
    if(response==1)
    {
    SetPlayerPos(playerid,1227.1797,-914.0590,42.6812);
    SendClientMessage(playerid,0xFFFF00FF,"Du wurdest Teleportiert");
    }
    if(response==0)
    {
    SendClientMessage(playerid,BLAU,"Ok dann halt nicht...");
    }
    }
    return 1;
    }


    public OnPlayerClickPlayer(playerid, clickedplayerid, source)
    {
    return 1;
    }


    stock SpielerName(playerid)
    {
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    return name;
    }


    stock Register(playerid,key[])
    {
    new Spielerdatei[64];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(Spielerdatei,sizeof(Spielerdatei),"/Accounts/%s.txt",name);
    dini_Create(Spielerdatei);
    dini_Set(Spielerdatei,"Passwort",key);
    SendClientMessage(playerid,BLAU,"Erfolgreich registriert.");
    SetPlayerScore(playerid,0);
    SetPVarInt(playerid,"loggedin",1);
    return 1;
    }


    stock Login(playerid,key[])
    {
    new Spielerdatei[64];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(Spielerdatei,sizeof(Spielerdatei),"/Accounts/%s.txt",name);
    if(!strcmp(key,dini_Get(Spielerdatei,"Passwort"),false))
    {
    LoadAccount(playerid);
    SendClientMessage(playerid,BLAU,"Erfolgreich eingeloggt.");
    return 1;
    }
    else
    {
    SendClientMessage(playerid,BLAU,"Falsches Passwort.");
    ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Dein Account wurde gefunden. Gib bitte das Passwort ein.","Login","Abbrechen");
    return 1;
    }
    }


    stock LoadAccount(playerid)
    {
    new Spielerdatei[64];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(Spielerdatei,sizeof(Spielerdatei),"/Accounts/%s.txt",name);
    SetPlayerScore(playerid,dini_Int(Spielerdatei,"Level"));
    GivePlayerMoney(playerid,dini_Int(Spielerdatei,"Geld"));
    SetPVarInt(playerid,"Adminlevel",dini_Int(Spielerdatei,"Adminlevel"));
    SetPVarInt(playerid,"Fraktion",dini_Int(Spielerdatei,"Fraktion"));
    SetPVarInt(playerid,"Baned",dini_Int(Spielerdatei,"Baned"));
    if(GetPVarInt(playerid,"Baned")==1)
    {
    SendClientMessage(playerid,ROT,"Du bist vom Server gebannt.");
    Kick(playerid);
    }
    SetPVarInt(playerid,"loggedin",1);
    return 1;
    }


    stock SpielerSpeichern(playerid)
    {
    if(GetPVarInt(playerid,"loggedin")==1)
    {
    new Spielerdatei[64];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(Spielerdatei,sizeof(Spielerdatei),"/Accounts/%s.txt",name);
    dini_IntSet(Spielerdatei,"Level",GetPlayerScore(playerid));
    dini_IntSet(Spielerdatei,"Geld",GetPlayerMoney(playerid));
    dini_IntSet(Spielerdatei,"Adminlevel",GetPVarInt(playerid,"Adminlevel"));
    dini_IntSet(Spielerdatei,"Fraktion",GetPVarInt(playerid,"Fraktion"));
    dini_IntSet(Spielerdatei,"Baned",GetPVarInt(playerid,"Baned"));
    }
    return 1;
    }


    stock isPlayerAnAdmin(playerid,rang)
    {
    if(GetPVarInt(playerid,"Adminlevel")>=rang)return 1;
    return 0;
    }


    stock sscanf(sstring[], format[], {Float,_}:...)
    {
    #if defined isnull
    if (isnull(sstring))
    #else
    if (sstring[0] == 0 || (sstring[0] == 1 && sstring[1] == 0))
    #endif
    {
    return format[0];
    }
    #pragma tabsize 4
    new
    formatPos = 0,
    sstringPos = 0,
    paramPos = 2,
    paramCount = numargs(),
    delim = ' ';
    while (sstring[sstringPos] && sstring[sstringPos] <= ' ')
    {
    sstringPos++;
    }
    while (paramPos < paramCount && sstring[sstringPos])
    {
    switch (format[formatPos++])
    {
    case '\0':
    {
    return 0;
    }
    case 'i', 'd':
    {
    new
    neg = 1,
    num = 0,
    ch = sstring[sstringPos];
    if (ch == '-')
    {
    neg = -1;
    ch = sstring[++sstringPos];
    }
    do
    {
    sstringPos++;
    if ('0' <= ch <= '9')
    {
    num = (num * 10) + (ch - '0');
    }
    else
    {
    return -1;
    }
    }
    while ((ch = sstring[sstringPos]) > ' ' && ch != delim);
    setarg(paramPos, 0, num * neg);
    }
    case 'h', 'x':
    {
    new
    num = 0,
    ch = sstring[sstringPos];
    do
    {
    sstringPos++;
    switch (ch)
    {
    case 'x', 'X':
    {
    num = 0;
    continue;
    }
    case '0' .. '9':
    {
    num = (num << 4) | (ch - '0');
    }
    case 'a' .. 'f':
    {
    num = (num << 4) | (ch - ('a' - 10));
    }
    case 'A' .. 'F':
    {
    num = (num << 4) | (ch - ('A' - 10));
    }
    default:
    {
    return -1;
    }
    }
    }
    while ((ch = sstring[sstringPos]) > ' ' && ch != delim);
    setarg(paramPos, 0, num);
    }
    case 'c':
    {
    setarg(paramPos, 0, sstring[sstringPos++]);
    }
    case 'f':
    {


    new changestr[16], changepos = 0, strpos = sstringPos;
    while(changepos < 16 && sstring[strpos] && sstring[strpos] != delim)
    {
    changestr[changepos++] = sstring[strpos++];
    }
    changestr[changepos] = '\0';
    setarg(paramPos,0,_:floatstr(changestr));
    }
    case 'p':
    {
    delim = format[formatPos++];
    continue;
    }
    case '\'':
    {
    new
    end = formatPos - 1,
    ch;
    while ((ch = format[++end]) && ch != '\'') {}
    if (!ch)
    {
    return -1;
    }
    format[end] = '\0';
    if ((ch = strfind(sstring, format[formatPos], false, sstringPos)) == -1)
    {
    if (format[end + 1])
    {
    return -1;
    }
    return 0;
    }
    format[end] = '\'';
    sstringPos = ch + (end - formatPos);
    formatPos = end + 1;
    }
    case 'u':
    {
    new
    end = sstringPos - 1,
    id = 0,
    bool:num = true,
    ch;
    while ((ch = sstring[++end]) && ch != delim)
    {
    if (num)
    {
    if ('0' <= ch <= '9')
    {
    id = (id * 10) + (ch - '0');
    }
    else
    {
    num = false;
    }
    }
    }
    if (num && IsPlayerConnected(id))
    {
    setarg(paramPos, 0, id);
    }
    else
    {
    #if !defined foreach
    #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
    #define __SSCANF_FOREACH__
    #endif
    sstring[end] = '\0';
    num = false;
    new
    name[MAX_PLAYER_NAME];
    id = end - sstringPos;
    foreach (Player, playerid)
    {
    GetPlayerName(playerid, name, sizeof (name));
    if (!strcmp(name, sstring[sstringPos], true, id))
    {
    setarg(paramPos, 0, playerid);
    num = true;
    break;
    }
    }
    if (!num)
    {
    setarg(paramPos, 0, INVALID_PLAYER_ID);
    }
    sstring[end] = ch;
    #if defined __SSCANF_FOREACH__
    #undef foreach
    #undef __SSCANF_FOREACH__
    #endif
    }
    sstringPos = end;
    }
    case 's', 'z':
    {
    new
    i = 0,
    ch;
    if (format[formatPos])
    {
    while ((ch = sstring[sstringPos++]) && ch != delim)
    {
    setarg(paramPos, i++, ch);
    }
    if (!i)
    {
    return -1;
    }
    }
    else
    {
    while ((ch = sstring[sstringPos++]))
    {
    setarg(paramPos, i++, ch);
    }
    }
    sstringPos--;
    setarg(paramPos, i, '\0');
    }
    default:
    {
    continue;
    }
    }
    while (sstring[sstringPos] && sstring[sstringPos] != delim && sstring[sstringPos] > ' ')
    {
    sstringPos++;
    }
    while (sstring[sstringPos] && (sstring[sstringPos] == delim || sstring[sstringPos] <= ' '))
    {
    sstringPos++;
    }
    paramPos++;
    }
    do
    {
    if ((delim = format[formatPos++]) > ' ')
    {
    if (delim == '\'')
    {
    while ((delim = format[formatPos++]) && delim != '\'') {}
    }
    else if (delim != 'z')
    {
    return delim;
    }
    }
    }
    while (delim > ' ');
    return 0;
    }