Spieler Spawnen lassen

In 10 Minuten startet der nächtliche Backupvorgang! Es kann währenddessen (ca. 10 Minuten) zu Einschränkungen bei der Nutzung des Forums kommen
Weitere Infos findet ihr im Thema Backup des Forums
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 Brotfische,
    ich habe in meinem Script im Moment fünf Fraktionen und möchte noch ein Paar einbauen. Allerdings ist das bissel komisch, wie ich die spawnen lasse.
    Ich habe es gerade so:

    if(PlayerInfo[playerid][pEingeloggt] == 0)
    {
    if(PlayerInfo[playerid][pFraktion] == 0)
    {
    new string[128],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(string,sizeof(string),"{FFFFFF}%s {999999}hat den Server betreten. Herzlich Willkommen!",name);
    SendClientMessageToAll(Grau,string);
    SetPlayerPos(playerid,2025.0194,1008.0113,10.8203);
    SetPlayerFacingAngle(playerid,266.3221);
    SetCameraBehindPlayer(playerid);
    SetPlayerColor(playerid,Zivi);
    SetPlayerSkin(playerid,1);
    PlayerInfo[playerid][pEingeloggt] = 1;
    SendDeathMessage(INVALID_PLAYER_ID,playerid,200);
    return 1;
    }
    if(PlayerInfo[playerid][pFraktion] == 1)
    {
    new string[128],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(string,sizeof(string),"{0077FF}%s {999999}hat den Server betreten. Herzlich Willkommen!",name);
    SendClientMessageToAll(Grau,string);
    SetPlayerPos(playerid,1569.7238,-1694.0360,5.8906);
    SetPlayerFacingAngle(playerid,178.3540);
    SetCameraBehindPlayer(playerid);
    SetPlayerColor(playerid,LSPD);
    SetPlayerSkin(playerid,266);
    PlayerInfo[playerid][pEingeloggt] = 1;
    SendDeathMessage(INVALID_PLAYER_ID,playerid,200);
    return 1;
    }
    if(PlayerInfo[playerid][pFraktion] == 2)
    {
    new string[128],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(string,sizeof(string),"{0026FF}%s {999999}hat den Server betreten. Herzlich Willkommen!",name);
    SendClientMessageToAll(Grau,string);
    SetPlayerPos(playerid,1050.7272,1006.7212,11.0000);
    SetPlayerFacingAngle(playerid,324.5735);
    SetCameraBehindPlayer(playerid);
    SetPlayerColor(playerid,FBI);
    SetPlayerSkin(playerid,285);
    PlayerInfo[playerid][pEingeloggt] = 1;
    SendDeathMessage(INVALID_PLAYER_ID,playerid,200);
    }
    if(PlayerInfo[playerid][pFraktion] == 3)
    {
    new string[128],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(string,sizeof(string),"{00FF15}%s {999999}hat den Server betreten. Herzlich Willkommen!",name);
    SendClientMessageToAll(Grau,string);
    SetPlayerPos(playerid,155.3963,1903.2561,18.6888);
    SetPlayerFacingAngle(playerid,271.1202);
    SetCameraBehindPlayer(playerid);
    SetPlayerColor(playerid,Army);
    SetPlayerSkin(playerid,287);
    PlayerInfo[playerid][pEingeloggt] = 1;
    SendDeathMessage(INVALID_PLAYER_ID,playerid,200);
    }
    if(PlayerInfo[playerid][pFraktion] == 4)
    {
    new string[128],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(string,sizeof(string),"{AA0000}%s {999999}hat den Server betreten. Herzlich Willkommen!",name);
    SendClientMessageToAll(Grau,string);
    SetPlayerPos(playerid,328.6095,-1512.7717,36.0391);
    SetPlayerFacingAngle(playerid,232.0174);
    SetCameraBehindPlayer(playerid);
    SetPlayerColor(playerid,Medic);
    SetPlayerSkin(playerid,70);
    PlayerInfo[playerid][pEingeloggt] = 1;
    SendDeathMessage(INVALID_PLAYER_ID,playerid,200);
    }
    if(PlayerInfo[playerid][pFraktion] == 5)
    {
    new string[128],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(string,sizeof(string),"{63CB63}%s {999999}hat den Server betreten. Herzlich Willkommen!",name);
    SendClientMessageToAll(Grau,string);
    SetPlayerPos(playerid,-2519.9355,-623.5046,132.7723);
    SetPlayerFacingAngle(playerid,2.7521);
    SetCameraBehindPlayer(playerid);
    SetPlayerColor(playerid,News);
    SetPlayerSkin(playerid,187);
    PlayerInfo[playerid][pEingeloggt] = 1;
    SendDeathMessage(INVALID_PLAYER_ID,playerid,200);
    }
    return 1;
    }
    else if(PlayerInfo[playerid][pEingeloggt] == 1)
    {
    if(PlayerInfo[playerid][pFraktion] == 0)
    {
    SetPlayerPos(playerid,2025.0194,1008.0113,10.8203);
    SetPlayerFacingAngle(playerid,266.3221);
    SetCameraBehindPlayer(playerid);
    SetPlayerColor(playerid,Zivi);
    SetPlayerSkin(playerid,1);
    PlayerInfo[playerid][pEingeloggt] = 1;
    return 1;
    }
    if(PlayerInfo[playerid][pFraktion] == 1)
    {
    SetPlayerPos(playerid,1569.7238,-1694.0360,5.8906);
    SetPlayerFacingAngle(playerid,178.3540);
    SetCameraBehindPlayer(playerid);
    SetPlayerColor(playerid,LSPD);
    SetPlayerSkin(playerid,266);
    PlayerInfo[playerid][pEingeloggt] = 1;
    return 1;
    }
    if(PlayerInfo[playerid][pFraktion] == 2)
    {
    SetPlayerPos(playerid,1050.7272,1006.7212,11.0000);
    SetPlayerFacingAngle(playerid,324.5735);
    SetCameraBehindPlayer(playerid);
    SetPlayerColor(playerid,FBI);
    SetPlayerSkin(playerid,285);
    PlayerInfo[playerid][pEingeloggt] = 1;
    return 1;
    }
    if(PlayerInfo[playerid][pFraktion] == 3)
    {
    SetPlayerPos(playerid,155.3963,1903.2561,18.6888);
    SetPlayerFacingAngle(playerid,271.1202);
    SetCameraBehindPlayer(playerid);
    SetPlayerColor(playerid,Army);
    SetPlayerSkin(playerid,287);
    PlayerInfo[playerid][pEingeloggt] = 1;
    return 1;
    }
    if(PlayerInfo[playerid][pFraktion] == 4)
    {
    SetPlayerPos(playerid,328.6095,-1512.7717,36.0391);
    SetPlayerFacingAngle(playerid,232.0174);
    SetCameraBehindPlayer(playerid);
    SetPlayerColor(playerid,Medic);
    SetPlayerSkin(playerid,70);
    PlayerInfo[playerid][pEingeloggt] = 1;
    return 1;
    }
    if(PlayerInfo[playerid][pFraktion] == 5)
    {
    SetPlayerPos(playerid,-2519.9355,-623.5046,132.7723);
    SetPlayerFacingAngle(playerid,2.7521);
    SetCameraBehindPlayer(playerid);
    SetPlayerColor(playerid,News);
    SetPlayerSkin(playerid,187);
    PlayerInfo[playerid][pEingeloggt] = 1;
    return 1;
    }
    }

    Kann ich das anders machen ? vielleicht sogar leichter ?

  • Geh mit dem Gedanken ran keine Zeilen doppelt zu schreiben.



    if(PlayerInfo[playerid][pEingeloggt] == 0)
    {
    new string[128],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(string,sizeof(string),"{FFFFFF}%s {999999}hat den Server betreten. Herzlich Willkommen!",name);
    SendClientMessageToAll(Grau,string);
    PlayerInfo[playerid][pEingeloggt] = 1;
    SendDeathMessage(INVALID_PLAYER_ID,playerid,200);
    }
    switch(PlayerInfo[playerid][pFraktion])
    {
    case 0:
    {
    SetPlayerPos(playerid,2025.0194,1008.0113,10.8203);
    SetPlayerFacingAngle(playerid,266.3221);
    SetCameraBehindPlayer(playerid);
    SetPlayerColor(playerid,Zivi);
    SetPlayerSkin(playerid,1);
    break;
    }
    case 1:
    {
    SetPlayerPos(playerid,1569.7238,-1694.0360,5.8906);
    SetPlayerFacingAngle(playerid,178.3540);
    SetCameraBehindPlayer(playerid);
    SetPlayerColor(playerid,LSPD);
    SetPlayerSkin(playerid,266);
    break;
    }
    case 2:
    {
    SetPlayerPos(playerid,1050.7272,1006.7212,11.0000);
    SetPlayerFacingAngle(playerid,324.5735);
    SetCameraBehindPlayer(playerid);
    SetPlayerColor(playerid,FBI);
    SetPlayerSkin(playerid,285);
    break;
    }
    case 3:
    {
    SetPlayerPos(playerid,155.3963,1903.2561,18.6888);
    SetPlayerFacingAngle(playerid,271.1202);
    SetCameraBehindPlayer(playerid);
    SetPlayerColor(playerid,Army);
    SetPlayerSkin(playerid,287);
    break;
    }
    case 4:
    {
    SetPlayerPos(playerid,328.6095,-1512.7717,36.0391);
    SetPlayerFacingAngle(playerid,232.0174);
    SetCameraBehindPlayer(playerid);
    SetPlayerColor(playerid,Medic);
    SetPlayerSkin(playerid,70);
    break;
    }
    case 5:
    {
    SetPlayerPos(playerid,-2519.9355,-623.5046,132.7723);
    SetPlayerFacingAngle(playerid,2.7521);
    SetCameraBehindPlayer(playerid);
    SetPlayerColor(playerid,News);
    SetPlayerSkin(playerid,187);
    break;
    }
    }


    #Edit
    SetCameraBehindPlayer(); sollte auch noch aus dem Switch-Case raus.

  • Du könntest es auch mit einem Enum regeln. Das könnte dann zB so aussehen: (Sorry, falls Fehler vorhanden sind. Bin auf Arbeit, und kann hier nichts testen).


    enum enum_FactionSpawns
    {
    Float:PosX,
    Float:PosY,
    Float:PosZ,
    Float:PosA,
    Color,
    Skin
    }
    new fSpawn[6][enum_FactionSpawns] = {
    {2025.0194,1008.0113,10.8203,266.3221,Zivi,1},
    {1569.7238,-1694.0360,5.8906,178.3540,LSPD,266},
    {1050.7272,1006.7212,11.0000,324.5735,FBI,285},
    {155.3963,1903.2561,18.6888,271.1202,Army,287},
    {328.6095,-1512.7717,36.0391,232.0174,Medic,70},
    {-2519.9355,-623.5046,132.7723,2.7521,News,187}
    }



    //OnPlayerSpawn (oder was auch immer :P)
    if(PlayerInfo[playerid][pEingeloggt] == 0)
    {
    new string[128],name[MAX_PLAYER_NAME],fid=PlayerInfo[playerid][pFraktion];
    GetPlayerName(playerid,name,sizeof(name));
    format(string,sizeof(string),"{FFFFFF}%s {999999}hat den Server betreten. Herzlich Willkommen!",name);
    SendClientMessageToAll(Grau,string);
    PlayerInfo[playerid][pEingeloggt] = 1;
    SendDeathMessage(INVALID_PLAYER_ID,playerid,200);
    }
    SetPlayerPos(playerid,fSpawn[fid][PosX],fSpawn[fid][PosY],fSpawn[fid][PosZ]);
    SetPlayerFacingAngle(playerid,fSpawn[fid][PosA]);
    SetCameraBehindPlayer(playerid);
    SetPlayerColor(playerid,fSpawn[fid][Color]);
    SetPlayerSkin(playerid,fSpawn[fid][Skin]);
    PlayerInfo[playerid][pEingeloggt] = 1;

  • Du könntest es auch mit einem Enum regeln. Das könnte dann zB so aussehen: (Sorry, falls Fehler vorhanden sind. Bin auf Arbeit, und kann hier nichts testen).

    Wenn es dynamisch sein sollte, würde ich das ganze mit einem SQL-Cache realisieren.
    Alle Fraktionen liegen in einer Datenbank, beim starten des Servers zieht er sich alle Fraktionen in einen Enum-Array.
    Nun kann er mittels Fraktions-ID direkt alle Informationen von den Fraktionen aus dem Array lesen / schreiben.
    Will er dann irgendwann mal die Position/den Namen/etc. ändern, kann das ohne Probleme direkt in der Datenbank gemacht werden.


    Dabei ist es egal ob es eine MySQL, SQLite, etc. ist.
    Aber nehm keine File basierte Speicherstruktur!

  • Ich habe das bei OnPlayerSpawn so gemacht:

    if(PlayerInfo[playerid][pEingeloggt] == 0)
    {
    new string[128],name[MAX_PLAYER_NAME],fID = PlayerInfo[playerid][pFraktion];
    GetPlayerName(playerid,name,sizeof(name));
    format(string,sizeof(string),"{FFFFFF}%s {999999}hat den Server betreten. Herzlich Willkommen!",name);
    SendClientMessageToAll(Grau,string);
    SetPlayerPos(playerid,FraktSpawns[fID][PosX],FraktSpawns[fID][PosY],FraktSpawns[fID][PosZ]);
    SetPlayerFacingAngle(playerid,FraktSpawns[fID][PosA]);
    SetCameraBehindPlayer(playerid);
    SetPlayerColor(playerid,FraktSpawns[fID][Color]);
    SetPlayerSkin(playerid,FraktSpawns[fID][Skin]);
    PlayerInfo[playerid][pEingeloggt] = 1;
    if(KillList == 1)
    {
    SendDeathMessage(INVALID_PLAYER_ID,playerid,200);
    }
    }
    else if(PlayerInfo[playerid][pEingeloggt] == 1)
    {
    new fID = PlayerInfo[playerid][pFraktion];
    SetPlayerPos(playerid,FraktSpawns[fID][PosX],FraktSpawns[fID][PosY],FraktSpawns[fID][PosZ]);
    SetPlayerFacingAngle(playerid,FraktSpawns[fID][PosA]);
    SetCameraBehindPlayer(playerid);
    SetPlayerColor(playerid,FraktSpawns[fID][Color]);
    SetPlayerSkin(playerid,FraktSpawns[fID][Skin]);
    PlayerInfo[playerid][pEingeloggt] = 1;
    }

    jetzt ist das aber so, dass wenn ich /makeleader Name 8 mache das da steht das ich Hitman Leader bin werde aber als Mülli gespawnt. Und wenn ich connecte steht doch dann immer in Weis statt in der Fraktionsfarbe: TheTutoFreak hat den Server betreten. Herzlich Willkommen!


    //PUSH Das Problem habe ich immer noch. :D