OnPlayerKeyStateChange

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
  • public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
    {
    if(newkeys == KEY_CROUCH)
    {
    if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == 2)
    {
    if(IsPlayerConnected(playerid))
    {
    new akveh = GetPlayerVehicleID(playerid);
    if(motors[akveh] == 0)
    {
    startmotor(akveh,playerid);
    }
    else if(motors[akveh] == 1)
    {
    stopmotor(akveh,playerid);
    }
    }
    }
    }
    return 1;
    }


    Hier habe ich ein Problem: Ich kann den Motor mit C starten, doch wenn ich nochmal drücke geht er nicht aus.

  • public OnPlayerStateChange(playerid, newstate, oldstate)
    {
    new CarID = GetPlayerVehicleID(playerid);
    new CarMod = GetVehicleModel(playerid);


    if(newstate == PLAYER_STATE_DRIVER)
    {
    if(VehicleStarted[CarID] == 0 && CarMod != 510 && CarMod != 509 && CarMod != 481)
    {
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 510 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 509 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 481){
    return 1;
    }
    TogglePlayerControllable(playerid,0);
    SCM(playerid,0x950000FF,"* Drücke TAB um den Motor zu starten");
    }else{
    SCM(playerid,0x80FF80FF,"* Motor ist schon an!");
    }
    }
    return 1;
    }


    public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
    {
    if((newkeys & (KEY_SECONDARY_ATTACK)) == (KEY_SECONDARY_ATTACK))
    {
    if(IsPlayerInAnyVehicle(playerid))
    {
    if(IsPlayerConnected(playerid))
    {
    new Vehicle = GetPlayerVehicleID(playerid);
    if(VehicleStarted[Vehicle] == 0)
    {
    RemovePlayerFromVehicle(playerid);
    SCM(playerid,0x0000FFFF,"* Dein motor ist nun wieder aus.");
    TogglePlayerControllable(playerid,1);
    }
    }
    }
    }


    if(newkeys == KEY_ACTION)
    {
    if(IsPlayerInAnyVehicle(playerid))
    {
    if(IsPlayerConnected(playerid))
    {
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 510 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 509 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 481){
    return 1;
    }
    new Vehicle = GetPlayerVehicleID(playerid);
    if(VehicleStarted[Vehicle] == 0)
    {
    new string[256];
    SCM(playerid,0x80FF80FF,"* Starte Motor...");
    GetPlayerName(playerid, sendername, sizeof(sendername));
    format(string, sizeof(string), "* %s Versucht den Motor zu starten.", sendername);
    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    GameTextForPlayer(playerid,"~n~~n~~n~~n~~n~~n~~n~~g~Motor gestartet...",3000,3);
    SetTimerEx("Starting",3500,0,"i",playerid);
    }
    }
    }
    }
    return 1;
    }


    so hab ich es und so geht es leider funtz mein FS nicht der läst ihn nicht registriren ;(

    Der Server: [GRG]Grand Racing Game wurde 2014 Eingestampft.
    Weitere Infos: Klick Mich

  • Machs nen in Den Script


    Mach dir nen Filterscript^^


    wieso error?
    C:\Dokumente und Einstellungen\Administrator\Desktop\Server14\samp02Xserver.win32\filterscripts\Mtor.pwn(75) : error 001: expected token: "#endif", but found "-end of file-"
    Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase



    1 Error.


    #include <a_samp>


    // This is a comment
    // uncomment the line below if you want to write a filterscript
    //#define FILTERSCRIPT


    #if defined FILTERSCRIPT


    public OnPlayerStateChange(playerid, newstate, oldstate)
    {
    new CarID = GetPlayerVehicleID(playerid);
    new CarMod = GetVehicleModel(playerid);


    if(newstate == PLAYER_STATE_DRIVER)
    {
    if(VehicleStarted[CarID] == 0 && CarMod != 510 && CarMod != 509 && CarMod != 481)
    {
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 510 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 509 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 481){
    return 1;
    }
    TogglePlayerControllable(playerid,0);
    SCM(playerid,0x950000FF,"* Drücke TAB um den Motor zu starten");
    }else{
    SCM(playerid,0x80FF80FF,"* Motor ist schon an!");
    }
    }
    return 1;
    }


    public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
    {
    if((newkeys & (KEY_SECONDARY_ATTACK)) == (KEY_SECONDARY_ATTACK))
    {
    if(IsPlayerInAnyVehicle(playerid))
    {
    if(IsPlayerConnected(playerid))
    {
    new Vehicle = GetPlayerVehicleID(playerid);
    if(VehicleStarted[Vehicle] == 0)
    {
    RemovePlayerFromVehicle(playerid);
    SCM(playerid,0x0000FFFF,"* Dein motor ist nun wieder aus.");
    TogglePlayerControllable(playerid,1);
    }
    }
    }
    }


    if(newkeys == KEY_ACTION)
    {
    if(IsPlayerInAnyVehicle(playerid))
    {
    if(IsPlayerConnected(playerid))
    {
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 510 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 509 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 481){
    return 1;
    }
    new Vehicle = GetPlayerVehicleID(playerid);
    if(VehicleStarted[Vehicle] == 0)
    {
    new string[256];
    SCM(playerid,0x80FF80FF,"* Starte Motor...");
    GetPlayerName(playerid, sendername, sizeof(sendername));
    format(string, sizeof(string), "* %s Versucht den Motor zu starten.", sendername);
    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    GameTextForPlayer(playerid,"~n~~n~~n~~n~~n~~n~~n~~g~Motor gestartet...",3000,3);
    SetTimerEx("Starting",3500,0,"i",playerid);
    }
    }
    }
    }
    return 1;
    }
    #endif


    xD hab das #endif vergessen xD^^

  • ich hab es als FS aber der erkennt ihn nicht an ;( kannst mir mal sagen warum im home ghet er


    Und hir ist kein error


    //Firstly Credits to Homer as this is just a small edit on top of his
    //Secondly please always leave my credits on this too
    //thirdly enjoy


    #include <a_samp>


    #define SCM SendClientMessage
    #define COLOR_PURPLE 0xC2A2DAAA



    new VehicleStarted[MAX_VEHICLES];
    new sendername[MAX_PLAYER_NAME];
    new BigEar[MAX_PLAYERS];


    forward Starting(playerid);
    forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);


    public OnFilterScriptInit()
    {
    print("-------------------------------------");
    print("-----Engine System By Lee Percox-----");
    print("---Credits to Lee Percox & Homer----");


    new Car;
    for(Car=0;Car<MAX_VEHICLES;Car++)
    return 1;
    return 1;
    }



    public OnFilterScriptExit()
    {
    return 1;
    }


    public OnPlayerCommandText(playerid, cmdtext[])
    {
    if(strcmp("/exitcar", cmdtext, true, 10) == 0) // you do not need to use this command as you just hit enter now
    {
    if(IsPlayerConnected(playerid))
    {
    if(IsPlayerInAnyVehicle(playerid))
    {
    RemovePlayerFromVehicle(playerid);
    SCM(playerid,0xFFFF00AA,"* You left the vehicle.");
    TogglePlayerControllable(playerid,1);
    }else{
    SCM(playerid,0xFFFF00AA,"* Du bist in kein Auto!");
    }
    }
    return 1;
    }
    return 0;
    }


    public OnPlayerStateChange(playerid, newstate, oldstate)
    {
    new CarID = GetPlayerVehicleID(playerid);
    new CarMod = GetVehicleModel(playerid);


    if(newstate == PLAYER_STATE_DRIVER)
    {
    if(VehicleStarted[CarID] == 0 && CarMod != 510 && CarMod != 509 && CarMod != 481)
    {
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 510 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 509 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 481){
    return 1;
    }
    TogglePlayerControllable(playerid,0);
    SCM(playerid,0x950000FF,"* Drücke TAB um den Motor zu starten");
    }else{
    SCM(playerid,0x80FF80FF,"* Motor ist schon an!");
    }
    }
    return 1;
    }


    public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
    {
    if((newkeys & (KEY_SECONDARY_ATTACK)) == (KEY_SECONDARY_ATTACK))
    {
    if(IsPlayerInAnyVehicle(playerid))
    {
    if(IsPlayerConnected(playerid))
    {
    new Vehicle = GetPlayerVehicleID(playerid);
    if(VehicleStarted[Vehicle] == 0)
    {
    RemovePlayerFromVehicle(playerid);
    SCM(playerid,0x0000FFFF,"* Dein motor ist nun wieder aus.");
    TogglePlayerControllable(playerid,1);
    }
    }
    }
    }


    if(newkeys == KEY_ACTION)
    {
    if(IsPlayerInAnyVehicle(playerid))
    {
    if(IsPlayerConnected(playerid))
    {
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 510 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 509 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 481){
    return 1;
    }
    new Vehicle = GetPlayerVehicleID(playerid);
    if(VehicleStarted[Vehicle] == 0)
    {
    new string[256];
    SCM(playerid,0x80FF80FF,"* Starte Motor...");
    GetPlayerName(playerid, sendername, sizeof(sendername));
    format(string, sizeof(string), "* %s Versucht den Motor zu starten.", sendername);
    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    GameTextForPlayer(playerid,"~n~~n~~n~~n~~n~~n~~n~~g~Motor gestartet...",3000,3);
    SetTimerEx("Starting",3500,0,"i",playerid);
    }
    }
    }
    }
    return 1;
    }


    public OnPlayerExitVehicle(playerid, vehicleid)
    {
    TogglePlayerControllable(playerid,1);
    new Vehicle = GetPlayerVehicleID(playerid);
    VehicleStarted[Vehicle] = 0;
    return 1;
    }


    public Starting(playerid)
    {
    new Vehicle = GetPlayerVehicleID(playerid);
    new RandomStart;
    if(IsPlayerConnected(playerid))
    {
    if(IsPlayerInAnyVehicle(playerid))
    {
    RandomStart = random(10);
    switch(RandomStart)
    {
    case 0,1,2,3,4,5,6,7,8,9:
    {
    new string[256];
    VehicleStarted[Vehicle] = 1;
    TogglePlayerControllable(playerid,1);
    GameTextForPlayer(playerid,"~r~Motor Gestartet", 1000, 1);
    GetPlayerName(playerid, sendername, sizeof(sendername));
    format(string, sizeof(string), "* %s startet den Motor.", sendername);
    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    }
    case 10:
    {
    new string[256];
    SendClientMessage(playerid,0xFF1C1CFF,"* Motor nicht gestartet!");
    format(string, sizeof(string), "* %s fails to start the Engine.", sendername);
    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    }
    }
    }
    }
    return 1;
    }


    public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
    {
    if(IsPlayerConnected(playerid))
    {
    new Float:posx, Float:posy, Float:posz;
    new Float:oldposx, Float:oldposy, Float:oldposz;
    new Float:tempposx, Float:tempposy, Float:tempposz;
    GetPlayerPos(playerid, oldposx, oldposy, oldposz);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(IsPlayerConnected(i))
    {
    if(!BigEar[i])
    {
    GetPlayerPos(i, posx, posy, posz);
    tempposx = (oldposx -posx);
    tempposy = (oldposy -posy);
    tempposz = (oldposz -posz);
    if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
    {
    SendClientMessage(i, col1, string);
    }
    else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
    {
    SendClientMessage(i, col2, string);
    }
    else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
    {
    SendClientMessage(i, col3, string);
    }
    else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
    {
    SendClientMessage(i, col4, string);
    }
    else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
    {
    SendClientMessage(i, col5, string);
    }
    }
    else
    {
    SendClientMessage(i, col1, string);
    }
    }
    }
    }
    return 1;
    }


    strtok(const string[], &index, const seperator[] = " ")
    {
    new index2, result[30];
    index2 = strfind(string, seperator, false, index);


    if(index2 == -1)
    {
    if(strlen(string) > index)
    {
    strmid(result, string, index, strlen(string), 30);
    index = strlen(string);
    }
    return result;
    }
    if(index2 > (index + 29))
    {
    index2 = index + 29;
    strmid(result, string, index, index2, 30);
    index = index2;
    return result;
    }
    strmid(result, string, index, index2, 30);
    index = index2 + 1;
    return result;
    }
    #pragma unused strtok

    Der Server: [GRG]Grand Racing Game wurde 2014 Eingestampft.
    Weitere Infos: Klick Mich

  • do.de - Domain-Offensive - Domains für alle und zu super Preisen
  • wenn dein Server online ist trag das mal in Filterscripts ein und mach ingame mal /rcon loadfs FSNAME

  • Bei mir gehts überhaupt net obwohl ich ihn eingetragen hab und wenn ich /rcon loadfs Mtor mache steht nix --

  • public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
    {
    new akveh = GetPlayerVehicleID(playerid);
    if(GetPlayerState(playerid) == 2)
    {
    if(motors[akveh] == 0)
    {
    if(newkeys == KEY_CROUCH)
    {
    if(IsPlayerInAnyVehicle(playerid))
    {
    if(IsPlayerConnected(playerid))
    {
    startmotor(akveh,playerid);
    }
    }
    }
    }
    else if(motors[akveh] == 1)
    {
    if(newkeys == KEY_CROUCH)
    {
    if(GetPlayerState(playerid) == 2)
    {
    stopmotor(akveh,playerid);
    }
    }
    }
    }
    }


    Der Motor lässt sich starten. Abschaltet auch nicht. Doch wenn ich die Taste zum abschalten während des Aussteigens drücke geht es irgentwie??? ?(