Script im Gamemode einbauen.

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 zusammen.
    Ich wollte gerne nach diesem Tutorial ein Bewegliches Tor beim LSPD einbauen(Es soll runterfahren in die Erde und nach ca 20 sekunden zu gehen).Und auch an anderen plätzen schranken die sich öffnen etc.
    Nur leider bekomme ich immer errors ab den teil wo ich etwas unter GameModeInit machen muss.
    Ich möchte das gerne beim Gamemode lvdm machen.Könntent ihr mir das villeicht einbauen oder eine kleine Anleitung schreiben damit ein Newbie der garkeine Ahnung vom scripten hat das einbauen kann?


    Währe echt nett.


    MfG

  • Wow danke für die schnelle Antwort.Schon zum zweiten mal sofortige hilfe bekommen.Sowas bin ich aus anderen Foren nicht gewohnt^^.
    Ich habe das nun weggemacht nur leider klappt das imme noch nicht.Sind die gleichen Errors wie vorher.Ich poste einfach mal meinen Code.
    //
    // RC BARNSTORM - A demonstration vehicle vs vehicle script for SA-MP 0.2
    // -- by kyeman (SA-MP team) 2007
    //
    // This script demonstrates the following :-
    // - An automatic vehicle observer mode switchable via a key press.
    // - Text drawing and the use of GTA ~k~ key constants.
    // - Use of RC vehicles
    // - Dynamic creation and destruction of vehicles
    // - The OnPlayerKeyStateChange event/callback and determining
    // if a key has just been pressed.
    // - Bypassing SA-MP's class selection with SetSpawnInfo


    #include <a_samp>
    #include <core>
    #include <float>


    forward gatezu1();


    new gPlayerVehicles[MAX_PLAYERS]; // the vehicleid for the active playerid
    new gPlayerObserving[MAX_PLAYERS]; // player observing which active player
    new Text:txtObsHelper;
    new gate1;
    new Float:gSpawnPositions[26][4] = { // positions where players in vehicles spawn
    {-205.7703,-119.6655,2.4094,342.0546},
    {-202.1386,-54.1213,2.4111,95.6799},
    {-197.2334,7.5293,2.4034,16.0852},
    {-135.7348,61.7265,2.4112,354.3534},
    {-73.7883,73.4238,2.4082,260.5399},
    {-6.9850,27.9988,2.4112,201.7691},
    {0.6782,-16.0898,2.4076,161.7720},
    {-46.3365,-88.3937,2.4092,180.7382},
    {-72.4389,-127.2939,2.4107,113.5616},
    {-128.1940,-144.1725,2.4094,78.9676},
    {-266.0189,-50.6718,2.4125,223.8079},
    {-244.2617,-1.0468,2.1038,257.3333},
    {-93.3146,-32.4889,2.4085,186.0631},
    {-130.7054,-93.4983,2.4124,73.8375},
    {-117.4049,4.2989,2.4112,337.1284},
    {-26.1622,135.8739,2.4094,248.1580},
    {45.5705,86.7586,2.0753,147.3342},
    {54.9881,2.2997,1.1132,95.7173},
    {-248.9905,-119.3982,2.4083,303.7859},
    {-60.1321,55.5239,2.4038,325.2209},
    {-60.9184,47.9302,5.7706,342.8299},
    {-70.0303,-22.0071,2.4113,165.2789},
    {-138.3093,-83.2640,2.4152,4.0455},
    {-25.5989,94.6100,2.4041,150.8322},
    {-161.0327,-70.5945,2.4042,142.9221},
    {-54.8308,-139.6148,2.4119,258.7639}
    };


    //------------------------------------------------------------------------------------------------------


    main()
    {
    print("Running: RC BARNSTORM by kyeman 2007");
    }


    //------------------------------------------------
    // ObserverSwitchToNextVehicle
    // Will increment the current observed player
    // until it finds a new player with an active vehicle.


    ObserverSwitchToNextVehicle(playerid)
    {
    new x=0;
    while(x!=MAX_PLAYERS) { // MAX_PLAYERS iterations
    gPlayerObserving[playerid]++;
    if(gPlayerObserving[playerid] == MAX_PLAYERS) {
    // we need to cycle back to the start
    gPlayerObserving[playerid] = 0;
    }
    // see if the target player has a vehicle,
    // if so assign this player to observe it
    if(gPlayerVehicles[gPlayerObserving[playerid]] != 0) {
    PlayerSpectateVehicle(playerid,gPlayerVehicles[gPlayerObserving[playerid]]);
    return;
    }
    x++;
    }
    // didn't find any vehicles to observe. we'll have to default to last
    PlayerSpectateVehicle(playerid,gPlayerVehicles[gPlayerObserving[playerid]]);
    }


    //------------------------------------------------
    // IsKeyJustDown. Returns 1 if the key
    // has just been pressed, 0 otherwise.


    IsKeyJustDown(key, newkeys, oldkeys)
    {
    if((newkeys & key) && !(oldkeys & key)) return 1;
    return 0;
    }


    //------------------------------------------------


    public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
    {
    if(newkeys == (VEHICLE_HORN))//wo die ** sind kommt die taste hin
    {
    if(PlayerToPoint(1, playerid, 265, 1959.9746, 1342.9863)//&&PlayerInfo[playerid][pMember] == 1||PlayerInfo[playerid][pLeader] == 1)wenn das ein fraktions gate sein soll
    //und *** sind die XYZ kordinaten wo man stehen muss damit das tor auf geht
    {
    MoveObject(gate1, 265, 1959.9746,-1342.9863, 2.5); // XYZ koordinaten wohin das tor auf geht 2.5 ist die geschwindigkeit
    SetTimer("gatezu1", 7000, 0);
    }
    }
    }


    //------------------------------------------------


    public OnPlayerConnect(playerid)
    {
    GameTextForPlayer(playerid,"~w~SA-MP: ~r~RC Barnstorm",5000,5);

    return 1;
    }


    //------------------------------------------------


    public OnPlayerDisconnect(playerid)
    {
    if(gPlayerVehicles[playerid]) {
    // Make sure their vehicle is destroyed when they leave.
    DestroyVehicle(gPlayerVehicles[playerid]);
    gPlayerVehicles[playerid] = 0;
    }
    return 0;
    }


    //------------------------------------------------
    //rcbarron = 464


    public OnPlayerSpawn(playerid)
    {
    // Create their own vehicle and put them in
    gPlayerVehicles[playerid] = CreateVehicle(464,
    gSpawnPositions[playerid][0],
    gSpawnPositions[playerid][1],
    gSpawnPositions[playerid][2],
    gSpawnPositions[playerid][3],
    -1,-1,10);


    PutPlayerInVehicle(playerid,gPlayerVehicles[playerid],0);
    //ForceClassSelection(playerid); // for next time they respawn
    TextDrawHideForPlayer(playerid, txtObsHelper);
    SetPlayerWorldBounds(playerid,200.0,-300.0,200.0,-200.0);
    return 1;
    }


    //------------------------------------------------


    public OnPlayerDeath(playerid, killerid, reason)
    {
    // We need to cleanup their vehicle
    RemovePlayerFromVehicle(gPlayerVehicles[playerid]);
    DestroyVehicle(gPlayerVehicles[playerid]);
    gPlayerVehicles[playerid] = 0;

    // Send the death information to all clients
    SendDeathMessage(killerid,playerid,reason);


    // If anyone was observing them, they'll have to switch to the next
    new x=0;
    while(x!=MAX_PLAYERS) {
    if(x != playerid && gPlayerObserving[x] == playerid) {
    ObserverSwitchToNextVehicle(x);
    }
    x++;
    }


    return 1;
    }


    //------------------------------------------------


    public OnPlayerRequestClass(playerid, classid)
    {
    // put them straight into observer mode, effectively
    // bypassing class selection.
    TogglePlayerSpectating(playerid,1);
    ObserverSwitchToNextVehicle(playerid);
    TextDrawShowForPlayer(playerid, txtObsHelper);


    // also force this dud spawn info upon them so that they
    // have spawn information set.
    SetSpawnInfo(playerid,0,0,
    gSpawnPositions[playerid][0],
    gSpawnPositions[playerid][1],
    gSpawnPositions[playerid][2],
    gSpawnPositions[playerid][3],
    -1,-1,-1,-1,-1,-1);

    return 0;
    }


    //------------------------------------------------


    public OnGameModeInit()


    {gate1 = CreateObject(object ID, X, Y, Z, rX, rY, rZ);
    SetGameModeText("RC Barnstorm");


    // General settings for the gamemode
    ShowPlayerMarkers(0);
    ShowNameTags(1);
    SetWorldTime(7);
    SetWeather(5);


    // Add a dud player class
    AddPlayerClass(0,0.0,0.0,4.0,0.0,-1,-1,-1,-1,-1,-1);

    // Init our globals
    new x=0;
    while(x!=MAX_PLAYERS) {
    gPlayerVehicles[x] = 0;
    gPlayerObserving[x] = (-1);
    x++;
    }

    // Init our observer helper text display
    txtObsHelper = TextDrawCreate(20.0, 400.0,
    "Press ~b~~k~~PED_SPRINT~ ~w~to spawn~n~Press ~b~~k~~PED_FIREWEAPON~ ~w~to switch players");
    TextDrawUseBox(txtObsHelper, 0);
    TextDrawFont(txtObsHelper, 2);
    TextDrawSetShadow(txtObsHelper,0);
    TextDrawSetOutline(txtObsHelper,1);
    TextDrawBackgroundColor(txtObsHelper,0x000000FF);
    TextDrawColor(txtObsHelper,0xFFFFFFFF);

    return 1;
    }



    //------------------------------------------------


    public OnPlayerUpdate(playerid)
    {
    /*
    new Keys,ud,lr;

    if(GetPlayerState(playerid) == PLAYER_STATE_SPECTATING) {
    GetPlayerKeys(playerid,Keys,ud,lr);
    if(ud > 0) {
    SendClientMessage(playerid, 0xFFFFFFFF, "DOWN");
    }
    else if(ud < 0) {
    SendClientMessage(playerid, 0xFFFFFFFF, "UP");
    }

    if(lr > 0) {
    SendClientMessage(playerid, 0xFFFFFFFF, "RIGHT");
    }
    else if(lr < 0) {
    SendClientMessage(playerid, 0xFFFFFFFF, "LEFT");
    }
    }*/

    return 1;
    }


    //------------------------------------------------
    public gatezu1()
    {
    MoveObject(gate1, X, Y, Z, 2.5); //2.5 ist die geschwindigkeit
    return 1;
    }


    Mir fällt grade auf das ich die falsche *.pwn bearbeite...Ich wollte eiegentlich Barre nehmen oder lvdm.Ich hoffe das ist egal.

    Einmal editiert, zuletzt von coolbib ()

  • OKay danke.Aber das das in dem Abschnitt geändert werden muss wusste ich nicht.Aber da hätte ich auch selbst drauf kommen können hätte ich mal gelesen.....Das eine ist ja für die Playerposition und das andere für das Object.Ich werde es später oder in 2Wochen testen da ich morgen weg bin.
    Ich danke dir für deine Hilfe.


    MfG