[SAMMELTHREAD] Kleine Scripting Fragen

Dein Problem konnte durch einen User gelöst werden? Bedank dich bei ihm indem du seinen Beitrag als Hilfreich markierst sowie einen Daumen oben dalässt
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
  • Dachte du meintest die Funktion, die auch in dem Thread war ..
    Jedenfalls klappts nun, danke dir ! ;)


    Nein, ich bin davon ausgegangen, dass ich dir die Funktion zum Berechnen des Speeds schon gegeben hatte, hatte ich aber gar nicht, mein Fehler. Aber so redet man manchmal an sich vorbei, kommt vor :D
    Gut, dass es jetzt funktioniert, viel Spaß damit.


    Übrigens sehe ich grade noch, das
    GetPlayerFacingAngle(playerid, a);
    kannst du aus der Funktion entfernen, das hat keine Verwendung (mehr) in der Funktion.

  • if(strcmp(cmdtext, "/destroyvehicle", true) == 0)
    {
    new vehicleid;
    new id;
    vehicleid= GetPlayerVehicleID(playerid);
    DestroyVehicle(vehicleid);
    PlayerPlaySound(playerid,1137,0.0,0.0,0.0);
    SendClientMessage(playerid, yellow,"* You have destroyed your vehicle.");
    if (!IsPlayerInAnyVehicle(id))SendClientMessage(playerid, 0xFF0000AA, "** You are not in a vehicle.");
    return 1;
    }


    Erhalte beide messages^^

  • if (!IsPlayerInAnyVehicle(id)) return SendClientMessage(playerid, 0xFF0000AA, "** You are not in a vehicle.");


    Bei dir fehlte unten das return bei SendClientMessage

    "Imagine if the government went after corruption as hard as it goes after guys who run filesharing sites. Priorities. " - @Snowden
    "More worrying than FBI temporarily running a server that contained child porn, is hacking computers anywhere in the world with one warrant" - @josephfcox

  • Mh, ich hab grad kA wie ich das anstellen soll, da ich das hier eingebaut haben möchte:



    //
    // Admin vehicle spawner using previews. For SA-MP 0.3x and above.
    // - Kye 2012
    //


    #include <a_samp>
    #include "../include/gl_common.inc"


    #define TOTAL_ITEMS 207
    #define SELECTION_ITEMS 21
    #define ITEMS_PER_LINE 7


    #define HEADER_TEXT "Vehicles"
    #define NEXT_TEXT "Next"
    #define PREV_TEXT "Prev"


    #define DIALOG_BASE_X 75.0
    #define DIALOG_BASE_Y 130.0
    #define DIALOG_WIDTH 550.0
    #define DIALOG_HEIGHT 180.0
    #define SPRITE_DIM_X 60.0
    #define SPRITE_DIM_Y 70.0


    new gTotalItems = TOTAL_ITEMS;
    new PlayerText:gCurrentPageTextDrawId[MAX_PLAYERS];
    new PlayerText:gHeaderTextDrawId[MAX_PLAYERS];
    new PlayerText:gBackgroundTextDrawId[MAX_PLAYERS];
    new PlayerText:gNextButtonTextDrawId[MAX_PLAYERS];
    new PlayerText:gPrevButtonTextDrawId[MAX_PLAYERS];
    new PlayerText:gSelectionItems[MAX_PLAYERS][SELECTION_ITEMS];
    new gSelectionItemsTag[MAX_PLAYERS][SELECTION_ITEMS];
    new gItemAt[MAX_PLAYERS];


    new gItemList[TOTAL_ITEMS] = {
    400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,
    431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,450,451,452,453,454,455,456,457,458,459,460,461,
    462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,
    493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523,
    524,525,526,527,528,529,530,531,532,533,534,535,536,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,
    555,556,557,558,559,560,561,562,563,564,565,566,567,568,571,572,573,574,575,576,577,578,579,580,581,582,583,584,585,
    586,587,588,589,590,591,592,593,594,595,596,597,598,599,600,601,602,603,604,605,606,607,608,609,610,611
    };


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


    GetNumberOfPages()
    {
    if((gTotalItems >= SELECTION_ITEMS) && (gTotalItems % SELECTION_ITEMS) == 0)
    {
    return (gTotalItems / SELECTION_ITEMS);
    }
    else return (gTotalItems / SELECTION_ITEMS) + 1;
    }


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


    PlayerText:CreateCurrentPageTextDraw(playerid, Float:Xpos, Float:Ypos)
    {
    new PlayerText:txtInit;
    txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, "0/0");
    PlayerTextDrawUseBox(playerid, txtInit, 0);
    PlayerTextDrawLetterSize(playerid, txtInit, 0.4, 1.1);
    PlayerTextDrawFont(playerid, txtInit, 1);
    PlayerTextDrawSetShadow(playerid, txtInit, 0);
    PlayerTextDrawSetOutline(playerid, txtInit, 1);
    PlayerTextDrawColor(playerid, txtInit, 0xACCBF1FF);
    PlayerTextDrawShow(playerid, txtInit);
    return txtInit;
    }


    //------------------------------------------------
    // Creates a button textdraw and returns the textdraw ID.


    PlayerText:CreatePlayerDialogButton(playerid, Float:Xpos, Float:Ypos, Float:Width, Float:Height, button_text[])
    {
    new PlayerText:txtInit;
    txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, button_text);
    PlayerTextDrawUseBox(playerid, txtInit, 1);
    PlayerTextDrawBoxColor(playerid, txtInit, 0x000000FF);
    PlayerTextDrawBackgroundColor(playerid, txtInit, 0x000000FF);
    PlayerTextDrawLetterSize(playerid, txtInit, 0.4, 1.1);
    PlayerTextDrawFont(playerid, txtInit, 1);
    PlayerTextDrawSetShadow(playerid, txtInit, 0); // no shadow
    PlayerTextDrawSetOutline(playerid, txtInit, 0);
    PlayerTextDrawColor(playerid, txtInit, 0x4A5A6BFF);
    PlayerTextDrawSetSelectable(playerid, txtInit, 1);
    PlayerTextDrawAlignment(playerid, txtInit, 2);
    PlayerTextDrawTextSize(playerid, txtInit, Height, Width); // The width and height are reversed for centering.. something the game does <g>
    PlayerTextDrawShow(playerid, txtInit);
    return txtInit;
    }

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


    PlayerText:CreatePlayerHeaderTextDraw(playerid, Float:Xpos, Float:Ypos, header_text[])
    {
    new PlayerText:txtInit;
    txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, header_text);
    PlayerTextDrawUseBox(playerid, txtInit, 0);
    PlayerTextDrawLetterSize(playerid, txtInit, 1.25, 3.0);
    PlayerTextDrawFont(playerid, txtInit, 0);
    PlayerTextDrawSetShadow(playerid, txtInit, 0);
    PlayerTextDrawSetOutline(playerid, txtInit, 1);
    PlayerTextDrawColor(playerid, txtInit, 0xACCBF1FF);
    PlayerTextDrawShow(playerid, txtInit);
    return txtInit;
    }


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


    PlayerText:CreatePlayerBackgroundTextDraw(playerid, Float:Xpos, Float:Ypos, Float:Width, Float:Height)
    {
    new PlayerText:txtBackground = CreatePlayerTextDraw(playerid, Xpos, Ypos,
    " ~n~"); // enough space for everyone
    PlayerTextDrawUseBox(playerid, txtBackground, 1);
    PlayerTextDrawBoxColor(playerid, txtBackground, 0x00000099);
    PlayerTextDrawLetterSize(playerid, txtBackground, 5.0, 5.0);
    PlayerTextDrawFont(playerid, txtBackground, 0);
    PlayerTextDrawSetShadow(playerid, txtBackground, 0);
    PlayerTextDrawSetOutline(playerid, txtBackground, 0);
    PlayerTextDrawColor(playerid, txtBackground,0x000000FF);
    PlayerTextDrawTextSize(playerid, txtBackground, Width, Height);
    PlayerTextDrawBackgroundColor(playerid, txtBackground, 0x00000099);
    PlayerTextDrawShow(playerid, txtBackground);
    return txtBackground;
    }


    //------------------------------------------------
    // Creates a model preview sprite


    PlayerText:CreateModelPreviewTextDraw(playerid, modelindex, Float:Xpos, Float:Ypos, Float:width, Float:height)
    {
    new PlayerText:txtPlayerSprite = CreatePlayerTextDraw(playerid, Xpos, Ypos, ""); // it has to be set with SetText later
    PlayerTextDrawFont(playerid, txtPlayerSprite, TEXT_DRAW_FONT_MODEL_PREVIEW);
    PlayerTextDrawColor(playerid, txtPlayerSprite, 0xFFFFFFFF);
    PlayerTextDrawBackgroundColor(playerid, txtPlayerSprite, 0x000000EE);
    PlayerTextDrawTextSize(playerid, txtPlayerSprite, width, height); // Text size is the Width:Height
    PlayerTextDrawSetPreviewModel(playerid, txtPlayerSprite, modelindex);
    PlayerTextDrawSetPreviewRot(playerid,txtPlayerSprite, -16.0, 0.0, -55.0);
    PlayerTextDrawSetSelectable(playerid, txtPlayerSprite, 1);
    PlayerTextDrawShow(playerid,txtPlayerSprite);
    return txtPlayerSprite;
    }


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


    DestroyPlayerModelPreviews(playerid)
    {
    new x=0;
    while(x != SELECTION_ITEMS) {
    if(gSelectionItems[playerid][x] != PlayerText:INVALID_TEXT_DRAW) {
    PlayerTextDrawDestroy(playerid, gSelectionItems[playerid][x]);
    gSelectionItems[playerid][x] = PlayerText:INVALID_TEXT_DRAW;
    }
    x++;
    }
    }


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


    ShowPlayerModelPreviews(playerid)
    {
    new x=0;
    new Float:BaseX = DIALOG_BASE_X;
    new Float:BaseY = DIALOG_BASE_Y - (SPRITE_DIM_Y * 0.33); // down a bit
    new linetracker = 0;

    new itemat = GetPVarInt(playerid, "vspawner_page") * SELECTION_ITEMS;

    // Destroy any previous ones created
    DestroyPlayerModelPreviews(playerid);


    while(x != SELECTION_ITEMS && itemat < gTotalItems) {
    if(linetracker == 0) {
    BaseX = DIALOG_BASE_X + 25.0; // in a bit from the box
    BaseY += SPRITE_DIM_Y + 1.0; // move on the Y for the next line
    }
    gSelectionItems[playerid][x] = CreateModelPreviewTextDraw(playerid, gItemList[itemat], BaseX, BaseY, SPRITE_DIM_X, SPRITE_DIM_Y);
    gSelectionItemsTag[playerid][x] = gItemList[itemat];
    BaseX += SPRITE_DIM_X + 1.0; // move on the X for the next sprite
    linetracker++;
    if(linetracker == ITEMS_PER_LINE) linetracker = 0;
    itemat++;
    x++;
    }
    }


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


    UpdatePageTextDraw(playerid)
    {
    new PageText[64+1];
    format(PageText, 64, "%d/%d", GetPVarInt(playerid,"vspawner_page") + 1, GetNumberOfPages());
    PlayerTextDrawSetString(playerid, gCurrentPageTextDrawId[playerid], PageText);
    }


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


    CreateSelectionMenu(playerid)
    {
    gBackgroundTextDrawId[playerid] = CreatePlayerBackgroundTextDraw(playerid, DIALOG_BASE_X, DIALOG_BASE_Y + 20.0, DIALOG_WIDTH, DIALOG_HEIGHT);
    gHeaderTextDrawId[playerid] = CreatePlayerHeaderTextDraw(playerid, DIALOG_BASE_X, DIALOG_BASE_Y, HEADER_TEXT);
    gCurrentPageTextDrawId[playerid] = CreateCurrentPageTextDraw(playerid, DIALOG_WIDTH - 30.0, DIALOG_BASE_Y + 15.0);
    gNextButtonTextDrawId[playerid] = CreatePlayerDialogButton(playerid, DIALOG_WIDTH - 30.0, DIALOG_BASE_Y+DIALOG_HEIGHT+100.0, 50.0, 16.0, NEXT_TEXT);
    gPrevButtonTextDrawId[playerid] = CreatePlayerDialogButton(playerid, DIALOG_WIDTH - 90.0, DIALOG_BASE_Y+DIALOG_HEIGHT+100.0, 50.0, 16.0, PREV_TEXT);


    ShowPlayerModelPreviews(playerid);
    UpdatePageTextDraw(playerid);
    }


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


    DestroySelectionMenu(playerid)
    {
    DestroyPlayerModelPreviews(playerid);


    PlayerTextDrawDestroy(playerid, gHeaderTextDrawId[playerid]);
    PlayerTextDrawDestroy(playerid, gBackgroundTextDrawId[playerid]);
    PlayerTextDrawDestroy(playerid, gCurrentPageTextDrawId[playerid]);
    PlayerTextDrawDestroy(playerid, gNextButtonTextDrawId[playerid]);
    PlayerTextDrawDestroy(playerid, gPrevButtonTextDrawId[playerid]);


    gHeaderTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
    gBackgroundTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
    gCurrentPageTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
    gNextButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
    gPrevButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
    }


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


    SpawnVehicle_InfrontOfPlayer(playerid, vehiclemodel, color1, color2)
    {
    new Float:x,Float:y,Float:z;
    new Float:facing;
    new Float:distance;


    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, facing);


    new Float:size_x,Float:size_y,Float:size_z;
    GetVehicleModelInfo(vehiclemodel, VEHICLE_MODEL_INFO_SIZE, size_x, size_y, size_z);

    distance = size_x + 0.5;


    x += (distance * floatsin(-facing, degrees));
    y += (distance * floatcos(-facing, degrees));


    facing += 90.0;
    if(facing > 360.0) facing -= 360.0;


    return CreateVehicle(vehiclemodel, x, y, z + (size_z * 0.25), facing, color1, color2, -1);
    }


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


    HandlePlayerItemSelection(playerid, selecteditem)
    {
    // In this case we're spawning a vehicle for them
    SpawnVehicle_InfrontOfPlayer(playerid, gSelectionItemsTag[playerid][selecteditem], -1, -1);
    }


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


    public OnPlayerConnect(playerid)
    {
    // Init all of the textdraw related globals
    gHeaderTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
    gBackgroundTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
    gCurrentPageTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
    gNextButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
    gPrevButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;

    for(new x=0; x < SELECTION_ITEMS; x++) {
    gSelectionItems[playerid][x] = PlayerText:INVALID_TEXT_DRAW;
    }

    gItemAt[playerid] = 0;

    return 1; // Allow other scripts to keep processing OnPlayerConnect
    }


    //-------------------------------------------
    // Even though only Player* textdraws are used in this script,
    // OnPlayerClickTextDraw is still required to handle ESC


    public OnPlayerClickTextDraw(playerid, Text:clickedid)
    {
    if(GetPVarInt(playerid, "vspawner_active") == 0) return 0;


    // Handle: They cancelled (with ESC)
    if(clickedid == Text:INVALID_TEXT_DRAW) {
    DestroySelectionMenu(playerid);
    SetPVarInt(playerid, "vspawner_active", 0);
    PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
    return 1;
    }

    return 0;
    }


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


    public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
    {
    if(GetPVarInt(playerid, "vspawner_active") == 0) return 0;


    new curpage = GetPVarInt(playerid, "vspawner_page");

    // Handle: next button
    if(playertextid == gNextButtonTextDrawId[playerid]) {
    if(curpage < (GetNumberOfPages() - 1)) {
    SetPVarInt(playerid, "vspawner_page", curpage + 1);
    ShowPlayerModelPreviews(playerid);
    UpdatePageTextDraw(playerid);
    PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
    } else {
    PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
    }
    return 1;
    }

    // Handle: previous button
    if(playertextid == gPrevButtonTextDrawId[playerid]) {
    if(curpage > 0) {
    SetPVarInt(playerid, "vspawner_page", curpage - 1);
    ShowPlayerModelPreviews(playerid);
    UpdatePageTextDraw(playerid);
    PlayerPlaySound(playerid, 1084, 0.0, 0.0, 0.0);
    } else {
    PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
    }
    return 1;
    }

    // Search in the array of textdraws used for the items
    new x=0;
    while(x != SELECTION_ITEMS) {
    if(playertextid == gSelectionItems[playerid][x]) {
    HandlePlayerItemSelection(playerid, x);
    PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
    DestroySelectionMenu(playerid);
    CancelSelectTextDraw(playerid);
    SetPVarInt(playerid, "vspawner_active", 0);
    return 1;
    }
    x++;
    }

    return 0;
    }


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


    public OnPlayerCommandText(playerid, cmdtext[])
    {
    new cmd[256+1];
    new idx;


    if(!IsPlayerAdmin(playerid)) return 0;

    cmd = strtok(cmdtext, idx);


    if(strcmp("/vspawner", cmd, true) == 0)
    {
    // If there was a previously created selection menu, destroy it
    DestroySelectionMenu(playerid);

    SetPVarInt(playerid, "vspawner_active", 1);
    //SetPVarInt(playerid, "vspawner_page", 0); // will reset the page back to the first

    CreateSelectionMenu(playerid);
    SelectTextDraw(playerid, 0xACCBF1FF);
    return 1;
    }

    return 0;
    }
    //------------------------------------------------


    ( V spawner von SA:MP )


    Könntest du mir da weiter helfen?

  • Könntest du mir da weiter helfen?


    Müsste so passen:

    Spoiler anzeigen
    //
    // Admin vehicle spawner using previews. For SA-MP 0.3x and above.
    // - Kye 2012
    //

    Spoiler anzeigen
    #include <a_samp>
    #include "../include/gl_common.inc"

    Spoiler anzeigen
    #define TOTAL_ITEMS 207
    #define SELECTION_ITEMS 21
    #define ITEMS_PER_LINE 7

    Spoiler anzeigen
    #define HEADER_TEXT "Vehicles"
    #define NEXT_TEXT "Next"
    #define PREV_TEXT "Prev"

    Spoiler anzeigen
    #define DIALOG_BASE_X 75.0
    #define DIALOG_BASE_Y 130.0
    #define DIALOG_WIDTH 550.0
    #define DIALOG_HEIGHT 180.0
    #define SPRITE_DIM_X 60.0
    #define SPRITE_DIM_Y 70.0

    Spoiler anzeigen
    new gTotalItems = TOTAL_ITEMS;
    new PlayerText:gCurrentPageTextDrawId[MAX_PLAYERS];
    new PlayerText:gHeaderTextDrawId[MAX_PLAYERS];
    new PlayerText:gBackgroundTextDrawId[MAX_PLAYERS];
    new PlayerText:gNextButtonTextDrawId[MAX_PLAYERS];
    new PlayerText:gPrevButtonTextDrawId[MAX_PLAYERS];
    new PlayerText:gSelectionItems[MAX_PLAYERS][SELECTION_ITEMS];
    new gSelectionItemsTag[MAX_PLAYERS][SELECTION_ITEMS];
    new gItemAt[MAX_PLAYERS];

    Spoiler anzeigen
    new adminCar[MAX_VEHICLES];

    Spoiler anzeigen
    new gItemList[TOTAL_ITEMS] = {
    400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,
    431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,450,451,452,453,454,455,456,457,458,459,460,461,
    462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,
    493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523,
    524,525,526,527,528,529,530,531,532,533,534,535,536,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,
    555,556,557,558,559,560,561,562,563,564,565,566,567,568,571,572,573,574,575,576,577,578,579,580,581,582,583,584,585,
    586,587,588,589,590,591,592,593,594,595,596,597,598,599,600,601,602,603,604,605,606,607,608,609,610,611
    };

    Spoiler anzeigen
    //------------------------------------------------

    Spoiler anzeigen
    GetNumberOfPages()
    {
    if((gTotalItems >= SELECTION_ITEMS) && (gTotalItems % SELECTION_ITEMS) == 0)
    {
    return (gTotalItems / SELECTION_ITEMS);
    }
    else return (gTotalItems / SELECTION_ITEMS) + 1;
    }

    Spoiler anzeigen
    //------------------------------------------------

    Spoiler anzeigen
    PlayerText:CreateCurrentPageTextDraw(playerid, Float:Xpos, Float:Ypos)
    {
    new PlayerText:txtInit;
    txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, "0/0");
    PlayerTextDrawUseBox(playerid, txtInit, 0);
    PlayerTextDrawLetterSize(playerid, txtInit, 0.4, 1.1);
    PlayerTextDrawFont(playerid, txtInit, 1);
    PlayerTextDrawSetShadow(playerid, txtInit, 0);
    PlayerTextDrawSetOutline(playerid, txtInit, 1);
    PlayerTextDrawColor(playerid, txtInit, 0xACCBF1FF);
    PlayerTextDrawShow(playerid, txtInit);
    return txtInit;
    }

    Spoiler anzeigen
    //------------------------------------------------
    // Creates a button textdraw and returns the textdraw ID.

    Spoiler anzeigen
    PlayerText:CreatePlayerDialogButton(playerid, Float:Xpos, Float:Ypos, Float:Width, Float:Height, button_text[])
    {
    new PlayerText:txtInit;
    txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, button_text);
    PlayerTextDrawUseBox(playerid, txtInit, 1);
    PlayerTextDrawBoxColor(playerid, txtInit, 0x000000FF);
    PlayerTextDrawBackgroundColor(playerid, txtInit, 0x000000FF);
    PlayerTextDrawLetterSize(playerid, txtInit, 0.4, 1.1);
    PlayerTextDrawFont(playerid, txtInit, 1);
    PlayerTextDrawSetShadow(playerid, txtInit, 0); // no shadow
    PlayerTextDrawSetOutline(playerid, txtInit, 0);
    PlayerTextDrawColor(playerid, txtInit, 0x4A5A6BFF);
    PlayerTextDrawSetSelectable(playerid, txtInit, 1);
    PlayerTextDrawAlignment(playerid, txtInit, 2);
    PlayerTextDrawTextSize(playerid, txtInit, Height, Width); // The width and height are reversed for centering.. something the game does <g>
    PlayerTextDrawShow(playerid, txtInit);
    return txtInit;
    }

    Spoiler anzeigen
    //------------------------------------------------

    Spoiler anzeigen
    PlayerText:CreatePlayerHeaderTextDraw(playerid, Float:Xpos, Float:Ypos, header_text[])
    {
    new PlayerText:txtInit;
    txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, header_text);
    PlayerTextDrawUseBox(playerid, txtInit, 0);
    PlayerTextDrawLetterSize(playerid, txtInit, 1.25, 3.0);
    PlayerTextDrawFont(playerid, txtInit, 0);
    PlayerTextDrawSetShadow(playerid, txtInit, 0);
    PlayerTextDrawSetOutline(playerid, txtInit, 1);
    PlayerTextDrawColor(playerid, txtInit, 0xACCBF1FF);
    PlayerTextDrawShow(playerid, txtInit);
    return txtInit;
    }

    Spoiler anzeigen
    //------------------------------------------------

    Spoiler anzeigen
    PlayerText:CreatePlayerBackgroundTextDraw(playerid, Float:Xpos, Float:Ypos, Float:Width, Float:Height)
    {
    new PlayerText:txtBackground = CreatePlayerTextDraw(playerid, Xpos, Ypos,
    " ~n~"); // enough space for everyone
    PlayerTextDrawUseBox(playerid, txtBackground, 1);
    PlayerTextDrawBoxColor(playerid, txtBackground, 0x00000099);
    PlayerTextDrawLetterSize(playerid, txtBackground, 5.0, 5.0);
    PlayerTextDrawFont(playerid, txtBackground, 0);
    PlayerTextDrawSetShadow(playerid, txtBackground, 0);
    PlayerTextDrawSetOutline(playerid, txtBackground, 0);
    PlayerTextDrawColor(playerid, txtBackground,0x000000FF);
    PlayerTextDrawTextSize(playerid, txtBackground, Width, Height);
    PlayerTextDrawBackgroundColor(playerid, txtBackground, 0x00000099);
    PlayerTextDrawShow(playerid, txtBackground);
    return txtBackground;
    }

    Spoiler anzeigen
    //------------------------------------------------
    // Creates a model preview sprite

    Spoiler anzeigen
    PlayerText:CreateModelPreviewTextDraw(playerid, modelindex, Float:Xpos, Float:Ypos, Float:width, Float:height)
    {
    new PlayerText:txtPlayerSprite = CreatePlayerTextDraw(playerid, Xpos, Ypos, ""); // it has to be set with SetText later
    PlayerTextDrawFont(playerid, txtPlayerSprite, TEXT_DRAW_FONT_MODEL_PREVIEW);
    PlayerTextDrawColor(playerid, txtPlayerSprite, 0xFFFFFFFF);
    PlayerTextDrawBackgroundColor(playerid, txtPlayerSprite, 0x000000EE);
    PlayerTextDrawTextSize(playerid, txtPlayerSprite, width, height); // Text size is the Width:Height
    PlayerTextDrawSetPreviewModel(playerid, txtPlayerSprite, modelindex);
    PlayerTextDrawSetPreviewRot(playerid,txtPlayerSprite, -16.0, 0.0, -55.0);
    PlayerTextDrawSetSelectable(playerid, txtPlayerSprite, 1);
    PlayerTextDrawShow(playerid,txtPlayerSprite);
    return txtPlayerSprite;
    }

    Spoiler anzeigen
    //------------------------------------------------

    Spoiler anzeigen
    DestroyPlayerModelPreviews(playerid)
    {
    new x=0;
    while(x != SELECTION_ITEMS) {
    if(gSelectionItems[playerid][x] != PlayerText:INVALID_TEXT_DRAW) {
    PlayerTextDrawDestroy(playerid, gSelectionItems[playerid][x]);
    gSelectionItems[playerid][x] = PlayerText:INVALID_TEXT_DRAW;
    }
    x++;
    }
    }

    Spoiler anzeigen
    //------------------------------------------------

    Spoiler anzeigen
    ShowPlayerModelPreviews(playerid)
    {
    new x=0;
    new Float:BaseX = DIALOG_BASE_X;
    new Float:BaseY = DIALOG_BASE_Y - (SPRITE_DIM_Y * 0.33); // down a bit
    new linetracker = 0;

    Spoiler anzeigen
    new itemat = GetPVarInt(playerid, "vspawner_page") * SELECTION_ITEMS;

    Spoiler anzeigen
    // Destroy any previous ones created
    DestroyPlayerModelPreviews(playerid);

    Spoiler anzeigen
    while(x != SELECTION_ITEMS && itemat < gTotalItems) {
    if(linetracker == 0) {
    BaseX = DIALOG_BASE_X + 25.0; // in a bit from the box
    BaseY += SPRITE_DIM_Y + 1.0; // move on the Y for the next line
    }
    gSelectionItems[playerid][x] = CreateModelPreviewTextDraw(playerid, gItemList[itemat], BaseX, BaseY, SPRITE_DIM_X, SPRITE_DIM_Y);
    gSelectionItemsTag[playerid][x] = gItemList[itemat];
    BaseX += SPRITE_DIM_X + 1.0; // move on the X for the next sprite
    linetracker++;
    if(linetracker == ITEMS_PER_LINE) linetracker = 0;
    itemat++;
    x++;
    }
    }

    Spoiler anzeigen
    //------------------------------------------------

    Spoiler anzeigen
    UpdatePageTextDraw(playerid)
    {
    new PageText[64+1];
    format(PageText, 64, "%d/%d", GetPVarInt(playerid,"vspawner_page") + 1, GetNumberOfPages());
    PlayerTextDrawSetString(playerid, gCurrentPageTextDrawId[playerid], PageText);
    }

    Spoiler anzeigen
    //------------------------------------------------

    Spoiler anzeigen
    CreateSelectionMenu(playerid)
    {
    gBackgroundTextDrawId[playerid] = CreatePlayerBackgroundTextDraw(playerid, DIALOG_BASE_X, DIALOG_BASE_Y + 20.0, DIALOG_WIDTH, DIALOG_HEIGHT);
    gHeaderTextDrawId[playerid] = CreatePlayerHeaderTextDraw(playerid, DIALOG_BASE_X, DIALOG_BASE_Y, HEADER_TEXT);
    gCurrentPageTextDrawId[playerid] = CreateCurrentPageTextDraw(playerid, DIALOG_WIDTH - 30.0, DIALOG_BASE_Y + 15.0);
    gNextButtonTextDrawId[playerid] = CreatePlayerDialogButton(playerid, DIALOG_WIDTH - 30.0, DIALOG_BASE_Y+DIALOG_HEIGHT+100.0, 50.0, 16.0, NEXT_TEXT);
    gPrevButtonTextDrawId[playerid] = CreatePlayerDialogButton(playerid, DIALOG_WIDTH - 90.0, DIALOG_BASE_Y+DIALOG_HEIGHT+100.0, 50.0, 16.0, PREV_TEXT);

    Spoiler anzeigen
    ShowPlayerModelPreviews(playerid);
    UpdatePageTextDraw(playerid);
    }

    Spoiler anzeigen
    //------------------------------------------------

    Spoiler anzeigen
    DestroySelectionMenu(playerid)
    {
    DestroyPlayerModelPreviews(playerid);

    Spoiler anzeigen
    PlayerTextDrawDestroy(playerid, gHeaderTextDrawId[playerid]);
    PlayerTextDrawDestroy(playerid, gBackgroundTextDrawId[playerid]);
    PlayerTextDrawDestroy(playerid, gCurrentPageTextDrawId[playerid]);
    PlayerTextDrawDestroy(playerid, gNextButtonTextDrawId[playerid]);
    PlayerTextDrawDestroy(playerid, gPrevButtonTextDrawId[playerid]);

    Spoiler anzeigen
    gHeaderTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
    gBackgroundTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
    gCurrentPageTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
    gNextButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
    gPrevButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
    }

    Spoiler anzeigen
    //------------------------------------------------

    Spoiler anzeigen
    SpawnVehicle_InfrontOfPlayer(playerid, vehiclemodel, color1, color2)
    {
    new Float:x,Float:y,Float:z;
    new Float:facing;
    new Float:distance;

    Spoiler anzeigen
    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, facing);

    Spoiler anzeigen
    new Float:size_x,Float:size_y,Float:size_z;
    GetVehicleModelInfo(vehiclemodel, VEHICLE_MODEL_INFO_SIZE, size_x, size_y, size_z);

    Spoiler anzeigen
    distance = size_x + 0.5;

    Spoiler anzeigen
    x += (distance * floatsin(-facing, degrees));
    y += (distance * floatcos(-facing, degrees));

    Spoiler anzeigen
    facing += 90.0;
    if(facing > 360.0) facing -= 360.0;

    Spoiler anzeigen
    return CreateVehicle(vehiclemodel, x, y, z + (size_z * 0.25), facing, color1, color2, -1);
    }

    Spoiler anzeigen
    //------------------------------------------------

    Spoiler anzeigen
    HandlePlayerItemSelection(playerid, selecteditem)
    {
    // In this case we're spawning a vehicle for them
    new vehicleid = SpawnVehicle_InfrontOfPlayer(playerid, gSelectionItemsTag[playerid][selecteditem], -1, -1);
    adminCar[vehicleid] = 1;
    }

    Spoiler anzeigen
    //------------------------------------------------

    Spoiler anzeigen
    public OnPlayerConnect(playerid)
    {
    // Init all of the textdraw related globals
    gHeaderTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
    gBackgroundTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
    gCurrentPageTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
    gNextButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
    gPrevButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;

    Spoiler anzeigen
    for(new x=0; x < SELECTION_ITEMS; x++) {
    gSelectionItems[playerid][x] = PlayerText:INVALID_TEXT_DRAW;
    }

    Spoiler anzeigen
    gItemAt[playerid] = 0;

    Spoiler anzeigen
    return 1; // Allow other scripts to keep processing OnPlayerConnect
    }

    Spoiler anzeigen
    //-------------------------------------------
    // Even though only Player* textdraws are used in this script,
    // OnPlayerClickTextDraw is still required to handle ESC

    Spoiler anzeigen
    public OnPlayerClickTextDraw(playerid, Text:clickedid)
    {
    if(GetPVarInt(playerid, "vspawner_active") == 0) return 0;

    Spoiler anzeigen
    // Handle: They cancelled (with ESC)
    if(clickedid == Text:INVALID_TEXT_DRAW) {
    DestroySelectionMenu(playerid);
    SetPVarInt(playerid, "vspawner_active", 0);
    PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
    return 1;
    }

    Spoiler anzeigen
    return 0;
    }

    Spoiler anzeigen
    //------------------------------------------------

    Spoiler anzeigen
    public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
    {
    if(GetPVarInt(playerid, "vspawner_active") == 0) return 0;

    Spoiler anzeigen
    new curpage = GetPVarInt(playerid, "vspawner_page");

    Spoiler anzeigen
    // Handle: next button
    if(playertextid == gNextButtonTextDrawId[playerid]) {
    if(curpage < (GetNumberOfPages() - 1)) {
    SetPVarInt(playerid, "vspawner_page", curpage + 1);
    ShowPlayerModelPreviews(playerid);
    UpdatePageTextDraw(playerid);
    PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
    } else {
    PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
    }
    return 1;
    }

    Spoiler anzeigen
    // Handle: previous button
    if(playertextid == gPrevButtonTextDrawId[playerid]) {
    if(curpage > 0) {
    SetPVarInt(playerid, "vspawner_page", curpage - 1);
    ShowPlayerModelPreviews(playerid);
    UpdatePageTextDraw(playerid);
    PlayerPlaySound(playerid, 1084, 0.0, 0.0, 0.0);
    } else {
    PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
    }
    return 1;
    }

    Spoiler anzeigen
    // Search in the array of textdraws used for the items
    new x=0;
    while(x != SELECTION_ITEMS) {
    if(playertextid == gSelectionItems[playerid][x]) {
    HandlePlayerItemSelection(playerid, x);
    PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
    DestroySelectionMenu(playerid);
    CancelSelectTextDraw(playerid);
    SetPVarInt(playerid, "vspawner_active", 0);
    return 1;
    }
    x++;
    }

    Spoiler anzeigen
    return 0;
    }

    Spoiler anzeigen
    //------------------------------------------------

    Spoiler anzeigen
    public OnPlayerCommandText(playerid, cmdtext[])
    {
    new cmd[256+1];
    new idx;

    Spoiler anzeigen
    if(!IsPlayerAdmin(playerid)) return 0;

    Spoiler anzeigen
    cmd = strtok(cmdtext, idx);

    Spoiler anzeigen
    if(strcmp("/vspawner", cmd, true) == 0)
    {
    // If there was a previously created selection menu, destroy it
    DestroySelectionMenu(playerid);

    Spoiler anzeigen
    SetPVarInt(playerid, "vspawner_active", 1);
    //SetPVarInt(playerid, "vspawner_page", 0); // will reset the page back to the first

    Spoiler anzeigen
    CreateSelectionMenu(playerid);
    SelectTextDraw(playerid, 0xACCBF1FF);
    return 1;
    }

    Spoiler anzeigen
    return 0;
    }
    //------------------------------------------------

    Spoiler anzeigen
    public OnVehicleSpawn(vehicleid)
    {
    if(adminCar[vehicleid]) DestroyVehicle(vehicleid);
    adminCar[vehicleid] = 0;
    return 1;
    }
    //------------------------------------------------


    Andreaas:
    http://pastebin.com/4BzKJnLn

    3HZXdYd.png

    Einmal editiert, zuletzt von Jeffry ()

  • Wie benutze ich Farben in solch einem Fall?


    Das kannst du so machen:
    new tmp[32 + 8];
    strcat(tmp,"~r~"),strcat(tmp,VehicleNames[car-400]);
    GameTextForPlayer(playerid, tmp, 2500, 1); //Jetzt wäre es rot wegen dem ~r~


    Hier alle Farben: http://wiki.sa-mp.com/wiki/GameTextStyle


    mfg. :thumbup:

    ast2ufdyxkb1.png


    Leute, lernt scripten und versucht mal lieber etwas selber zu schreiben, als es aus einem GF zu kopieren. :S


  • Diese funktionieren jedoch musst du das über OnPlayerUpdate lösen mit der Funktion GetPlayerKey eventuell erkennst du darüber auch die Restlichen Numpad-Tasten.


    Warum ist das so ?
    Das liegt daran das dieses Callback sonst zu oft aufgerufen werden würde(könnte zu laggs führen), daher wurden nur bestimmte Tasten verwendet.


    Ist etwas länger her..
    Jedoch klappt es nicht, auch wenn ich es unter "OnPlayerUpdate" versuche..


    Code


    new keys, ud, lr;
    GetPlayerKeys(playerid, keys, ud, lr);
    if(ud & KEY_UP || ud & -128)GibtGas[playerid] = true;
    else GibtGas[playerid] = false;


    //Edit:
    Habe einen weiteren Fehler..
    Jeffry: hat mir ja eine Funktion gegeben, die die Geschwindikeit des Spielers verändert, jedoch verändert es die Geschwindigkeit doch nicht..
    Ich habe mir die Geschwindigkeit immer ausgeben lassen usw, und es sah so aus, als ob es klappt..


    Die Geschwindigkeit verändert sich nur, wenn ich laufe und dabei springe. Dann verändert sie sich aber nicht um die Geschwindigkeit, die ich angegeben habe, sondern um 100, 200 , 2000, 3000 ( unterschiedlich ) km/h ..


    Hier nochmal ein Versuch, die Geschwindigkeit auf 30 km/h zu stellen ( OnPlayerUpdate )
    if(!IsPlayerInAnyVehicle(playerid) && !Jumped[playerid])
    {
    new Float:speed; GetPlayerSpeed_New(playerid,speed);
    return SetPlayerSpeed(playerid,30.0,speed);
    }


    Und hier nochmal die Funktionen "GetPlayerSpeed_New" & "SetPlayerSpeed"

    stock GetPlayerSpeed_New(playerid, &Float:speed) // By: [XST]O_x
    {
    new Float:ST[4];
    if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid)!=PLAYER_STATE_PASSENGER)
    GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]);
    else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
    ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 100.3;
    speed = ST[3];
    return 1;
    }
    stock SetPlayerSpeed(playerid, Float:_speed, Float:_isspeed){
    if(playerid == INVALID_PLAYER_ID)return INVALID_PLAYER_ID;
    if(IsPlayerNPC(playerid))return 1;
    if(IsPlayerInAnyVehicle(playerid))return 1;
    new Float:x1, Float:y1, Float:z1;
    GetPlayerVelocity(playerid, x1, y1, z1);
    return SetPlayerVelocity(playerid, x1*(1+(1/(1+(_speed/_isspeed)))), y1*(1+(1/(1+(_speed/_isspeed)))), z1);
    }


    Ist irgendwas falsch? ..

    Mit freundlichen Grüßen
    ErikSon



    Scripte kleine Systeme auf Anfrage umsonst!
    Per PN könnt ihr mir gerne Scriptingfragen stellen.

    Einmal editiert, zuletzt von ErikSon ()

  • Server crasht beim ausführen dieses commands:


    if(!strcmp(cmdtext, "/coordinates", true) || !strcmp(cmdtext, "/myposition", true))
    {
    new str[128], Float: xPos[3], xInterior = GetPlayerInterior(playerid), xVirtualWorld = GetPlayerVirtualWorld(playerid);
    GetPlayerPos(playerid, xPos[0], xPos[1], xPos[2]);
    format(str, sizeof(str), "X: %.3f, Y: %.3f, Z: %.3f Interior: %d, Virtual World: %d", xPos[0], xPos[1], xPos[2], xInterior, xVirtualWorld);
    SendClientMessage(playerid,COLOR_MAUVE,str);
    return 1;
    }


  • Das habe ich doch verwendet..
    Habe auch anstatt
    ud & -128 //&
    ud & KEY_UP // &
    ud == KEY_UP // &
    ud & KEY_UP


    So versucht:
    keys & KEY_UP // &
    keys == KEY_UP // &
    keys & -128 // &
    keys == -128


    Jedoch klappt nichts davon ..