Fahrzeug nur für Besitzer zugänglich machen

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
  • Hallooo Zusammen


    ich brauche eine Überprüfung, ob der Fahrer der Besitzer des Fahrzeugs ist, somit soll dann NUr dann wenn er halt der Besitzer ist soll der Kilometerstand sich erhöhen


    Zurzeit habe ich das Problem dass die KMH und die Kilometeranzeige rumspinnt, wenn 2 Spieler gleichzeitg fahren


    Hier der KMH Teil


    Spoiler anzeigen
    public Tachosek()
    {
    new string[128];
    for(new i=0; i<MAX_PLAYERS; i++)
    {
    if(!IsPlayerConnected(i))continue;
    if(!IsPlayerInAnyVehicle(i))continue;
    if(!IsPlayerInAnyVehicle(i))continue;
    format(string,sizeof(string),"d",getPlayerSpeed(i));
    TextDrawSetString(Textdraw23,string);
    //format(string,sizeof(string),"%ikm/h", getPlayerSpeed(i));
    //GameTextForPlayer(i, string, 1000, 3);


    }
    return 1;
    }




    und hier der Kilometerteil



    Spoiler anzeigen
    public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)//mom
    {
    return 1;
    }
    public zehn(vehicleid)
    {

    Spoiler anzeigen
    for(new i;i<MAX_PLAYERS;i++) {
    if(!IsPlayerConnected(i))continue;
    if(!IsPlayerInAnyVehicle(i))continue;
    new Float:Distanz,km2[32];
    GetVehiclePos(vehicleid,pNewKM[0][i],pNewKM[1][i],pNewKM[2][i]);
    Distanz=GetVehicleDistanceFromPoint(vehicleid,pOldKM[0][i],pOldKM[1][i],pOldKM[2][i]);
    if(Distanz > 150){ Distanz=0; }
    cInfo[i][kmstand] += Distanz/1000;
    pOldKM[0][i] = pNewKM[0][i];
    pOldKM[1][i] = pNewKM[1][i];//Damit die schleife da bleibt kk ^^ kk = ok
    pOldKM[2][i] = pNewKM[2][i];
    format(km2,sizeof km2,"%0.2f",cInfo[i][kmstand]);
    //SendClientMessage(i,-1,"Kilometerstand aktualisiert");
    TextDrawSetString(Textdraw25, km2);//Das cInfo [kmstand]sollte besser eine Float sein, da man damit finde ich präziser arbeiten kann ok könntest du evtl Speichern und auslesen noch überprüfen glaube habe da auch gefailt klar
    }
    return 1;
    }

    Spoiler anzeigen
    public OnPlayerExitVehicle(playerid, vehicleid)
    {
    TextDrawHideForPlayer(playerid,Textdraw20);
    TextDrawHideForPlayer(playerid,Textdraw21);
    TextDrawHideForPlayer(playerid,Textdraw22);
    TextDrawHideForPlayer(playerid,Textdraw23);
    TextDrawHideForPlayer(playerid,Textdraw24);
    TextDrawHideForPlayer(playerid,Textdraw25);
    TextDrawHideForPlayer(playerid,Textdraw26);
    saveCarToDB(playerid,vehicleid);
    return 1;
    }

    Spoiler anzeigen
    public OnPlayerStateChange(playerid, newstate, oldstate)
    {




    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER) // Player entered a vehicle as a driver
    {
    {
    new vehicleid=GetPlayerVehicleID(playerid);
    TextDrawShowForPlayer(playerid,Textdraw20);
    TextDrawShowForPlayer(playerid,Textdraw21);
    TextDrawShowForPlayer(playerid,Textdraw22);
    TextDrawShowForPlayer(playerid,Textdraw23);
    TextDrawShowForPlayer(playerid,Textdraw24);
    TextDrawShowForPlayer(playerid,Textdraw25);
    TextDrawShowForPlayer(playerid,Textdraw26);

    zehn(vehicleid);
    GetPlayerVehicleID(playerid);
    GetVehiclePos(GetPlayerVehicleID(playerid),pOldKM[0][playerid],pOldKM[1][playerid],pOldKM[2][playerid]);
    SetTimerEx("zehn",1000,true,"d",GetPlayerVehicleID(playerid));
    }


    Spoiler anzeigen
    if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT) // Player went out of a vehicle as a driver
    {
    TextDrawHideForPlayer(playerid,Textdraw20);
    TextDrawHideForPlayer(playerid,Textdraw21);
    TextDrawHideForPlayer(playerid,Textdraw22);
    TextDrawHideForPlayer(playerid,Textdraw23);
    TextDrawHideForPlayer(playerid,Textdraw24);
    TextDrawHideForPlayer(playerid,Textdraw25);
    TextDrawHideForPlayer(playerid,Textdraw26);
    }



    Bin selbstverständlich auch über Teamviewer erreichbar, danke für jede Hilfe

  • Nur damit ich dass dann nicht falsch Mache


    CreatePlayerTextDraw
    soll doch dann auch unter Ongamemode INIt oder?
    folgende Variablen werden ja verlangt
    playerid,X,Y,Text
    x,Y,TExt habe ich aber wie definiere ich dann die playerid???
    Ich weiß ich bin ein spätchecker
    aber danke :D

  • okay mit dem Array da muss ich dann einfach nur [playerid] durch [db_id] ersetzen


    (db_id) ist die definierte Spielerid im enum


    hier nochmals mein ENUM


    Spoiler anzeigen
    enum playerInfo{
    eingeloggt,
    level,
    db_id,
    fraktion,
    rang,
    alevel,
    spawnchange,
    PaydayTime,
    Payday,
    autoschein,
    rollerschein,
    geld,
    adname,
    pGesperrt,
    premiumlevel,
    premiumzeit[2],
    premiumGivenBy[MAX_PLAYER_NAME],
    premiumGivenTS,
    premiumSys,

  • okay probier ich mal aus, poste es gleich nochmal zur Sicherheit



    EDIT1:



    Spoiler anzeigen
    //TEXTDRAWS Tacho und Geschwindigkeit

    Textdraw20[playerid] = CreatePlayerTextDraw(playerid,411.000000, 337.000000, "Geschwindigkeit:");
    TextDrawBackgroundColor(Textdraw20, 65535);
    TextDrawFont(Textdraw20 , 1);
    TextDrawLetterSize(Textdraw20, 0.500000, 1.900000);
    TextDrawColor(Textdraw20, -65281);
    TextDrawSetOutline(Textdraw20 ,1);
    TextDrawSetProportional(Textdraw20, 1);
    TextDrawUseBox(Textdraw20 ,1);
    TextDrawBoxColor(Textdraw20, 65535);
    TextDrawTextSize(Textdraw20 ,610.000000, 0.000000);

    Spoiler anzeigen
    Textdraw21[playerid] = CreatePlayerTextDraw(playerid,573.000000, 339.000000, "KM/H");
    TextDrawBackgroundColor(Textdraw21 , 255);
    TextDrawFont(Textdraw21 , 1);
    TextDrawLetterSize(Textdraw21 , 0.440000, 1.600000);
    TextDrawColor(Textdraw21, -65281);
    TextDrawSetOutline(Textdraw21, 0);
    TextDrawSetProportional(Textdraw21, 1);
    TextDrawSetShadow(Textdraw21, 1);

    Spoiler anzeigen

    Textdraw23[playerid] = CreatePlayerTextDraw(playerid,553.000000, 338.000000, "");
    TextDrawBackgroundColor(Textdraw23, 255);
    TextDrawFont(Textdraw23, 1);
    TextDrawLetterSize(Textdraw23, 0.269998, 1.799999);
    TextDrawColor(Textdraw23, -16776961);
    TextDrawSetOutline(Textdraw23, 0);
    TextDrawSetProportional(Textdraw23, 1);
    TextDrawSetShadow(Textdraw23, 1);

    Spoiler anzeigen

    //Kilometerstand


    Textdraw24[playerid] = CreatePlayerTextDraw(playerid,411.000000, 360.000000, "Kilometerstand:");
    TextDrawBackgroundColor(Textdraw24, 255);
    TextDrawFont(Textdraw24, 1);
    TextDrawLetterSize(Textdraw24, 0.500000, 2.099999);
    TextDrawColor(Textdraw24, -65281);
    TextDrawSetOutline(Textdraw24, 0);
    TextDrawSetProportional(Textdraw24, 1);
    TextDrawSetShadow(Textdraw24, 1);
    TextDrawUseBox(Textdraw24, 1);
    TextDrawBoxColor(Textdraw24, 65535);
    TextDrawTextSize(Textdraw24, 610.000000, -1.000000);

    Spoiler anzeigen
    Textdraw25[playerid] = CreatePlayerTextDraw(playerid,540.000000, 362.000000, "000");
    TextDrawBackgroundColor(Textdraw25, 255);
    TextDrawFont(Textdraw25, 1);
    TextDrawLetterSize(Textdraw25, 0.390000, 1.900000);
    TextDrawColor(Textdraw25, -16776961);
    TextDrawSetOutline(Textdraw25, 0);
    TextDrawSetProportional(Textdraw25, 1);
    TextDrawSetShadow(Textdraw25, 1);

    Spoiler anzeigen
    Textdraw26[playerid] = CreatePlayerTextDraw(playerid,586.000000, 363.000000, "KM");
    TextDrawBackgroundColor(Textdraw26, 255);
    TextDrawFont(Textdraw26, 1);
    TextDrawLetterSize(Textdraw26, 0.500000, 1.700000);
    TextDrawColor(Textdraw26, -65281);
    TextDrawSetOutline(Textdraw26, 0);
    TextDrawSetProportional(Textdraw26, 1);
    TextDrawSetShadow(Textdraw26, 1);



    so??

  • do.de - Domain-Offensive - Domains für alle und zu super Preisen
  • also so

    Spoiler anzeigen

    Textdraw20[playerid] = CreatePlayerTextDraw(playerid,411.000000, 337.000000, "Geschwindigkeit:");
    TextDrawBackgroundColor(Textdraw20[playerid], 65535);
    TextDrawFont(Textdraw20[playerid] , 1);
    TextDrawLetterSize(Textdraw20[playerid], 0.500000, 1.900000);
    TextDrawColor(Textdraw20[playerid], -65281);
    TextDrawSetOutline(Textdraw20[playerid] ,1);
    TextDrawSetProportional(Textdraw20[playerid], 1);
    TextDrawUseBox(Textdraw20[playerid] ,1);
    TextDrawBoxColor(Textdraw20[playerid], 65535);
    TextDrawTextSize(Textdraw20[playerid] ,610.000000, 0.000000);

  • ok mach ich noch eben



    EDIT1:


    so


    Spoiler anzeigen
    Textdraw26[playerid] = CreatePlayerTextDraw(playerid,586.000000, 363.000000, "KM");
    PlayerTextDrawBackgroundColor(Textdraw26[playerid], 255);
    PlayerTextDrawFont(Textdraw26[playerid], 1);
    PlayerTextDrawLetterSize(Textdraw26[playerid], 0.500000, 1.700000);
    PlayerTextDrawColor(Textdraw26[playerid], -65281);
    PlayerTextDrawSetOutline(Textdraw26[playerid], 0);
    PlayerTextDrawSetProportional(Textdraw26[playerid], 1);
    PlayerTextDrawSetShadow(Textdraw26[playerid], 1);



    EDIT2: Folgenden Error:


    E:\SAMP\gamemodes\Script1.pwn(1392) : error 028: invalid subscript (not an array or too many subscripts): "Textdraw20"
    E:\SAMP\gamemodes\Script1.pwn(1392) : warning 215: expression has no effect
    E:\SAMP\gamemodes\Script1.pwn(1392) : error 001: expected token: ";", but found "]"
    E:\SAMP\gamemodes\Script1.pwn(1392) : error 029: invalid expression, assumed zero
    E:\SAMP\gamemodes\Script1.pwn(1392) : fatal error 107: too many error messages on one line


    Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase



    4 Errors.

    Einmal editiert, zuletzt von akinoratex ()

  • Siehe EDIT 2:




    E:\SAMP\gamemodes\Script1.pwn(1392) : error 028: invalid subscript (not an array or too many subscripts): "Textdraw20"
    E:\SAMP\gamemodes\Script1.pwn(1392) : warning 215: expression has no effect
    E:\SAMP\gamemodes\Script1.pwn(1392) : error 001: expected token: ";", but found "]"
    E:\SAMP\gamemodes\Script1.pwn(1392) : error 029: invalid expression, assumed zero
    E:\SAMP\gamemodes\Script1.pwn(1392) : fatal error 107: too many error messages on one line


    Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase



    Hier nochmal die LINE


    Spoiler anzeigen
    Textdraw20[playerid] = CreatePlayerTextDraw(playerid,411.000000, 337.000000, "Geschwindigkeit:");


    4 Errors.

  • Super danke :D


    EDIT 1: Nun folgende Errors


    E:\SAMP\gamemodes\Script1.pwn(1393) : error 017: undefined symbol "Textdraw20"
    E:\SAMP\gamemodes\Script1.pwn(1393) : warning 215: expression has no effect
    E:\SAMP\gamemodes\Script1.pwn(1393) : error 001: expected token: ";", but found "]"
    E:\SAMP\gamemodes\Script1.pwn(1393) : error 029: invalid expression, assumed zero
    E:\SAMP\gamemodes\Script1.pwn(1393) : fatal error 107: too many error messages on one line


    Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase



    4 Errors.



    habs aber editiert:

    new PlayerText:TextDraw20[MAX_PLAYERS];
    new PlayerText:TextDraw21[MAX_PLAYERS];
    new PlayerText:TextDraw22[MAX_PLAYERS];
    new PlayerText:TextDraw23[MAX_PLAYERS];
    new PlayerText:TextDraw24[MAX_PLAYERS];
    new PlayerText:TextDraw25[MAX_PLAYERS];
    new PlayerText:TextDraw26[MAX_PLAYERS];



    Hier nochmal die LINE

    Textdraw20[playerid] = CreatePlayerTextDraw(playerid,411.000000, 337.000000, "Geschwindigkeit:");
    PlayerTextDrawBackgroundColor(Textdraw20[playerid], 65535);
    PlayerTextDrawFont(Textdraw20[playerid] , 1);
    PlayerTextDrawLetterSize(Textdraw20[playerid], 0.500000, 1.900000);
    PlayerTextDrawColor(Textdraw20[playerid], -65281);
    PlayerTextDrawSetOutline(Textdraw20[playerid] ,1);
    PlayerTextDrawSetProportional(Textdraw20[playerid], 1);
    PlayerTextDrawUseBox(Textdraw20[playerid] ,1);
    PlayerTextDrawBoxColor(Textdraw20[playerid], 65535);
    PlayerTextDrawTextSize(Textdraw20[playerid] ,610.000000, 0.000000);




    die 1. Line ist gemeint