Adminsicht

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
  • C:\Users\valen\Desktop\mrmonat\MySQL Sciptfiles\gamemodes\beispiel.pwn(230) : error 029: invalid expression, assumed zero

    Du hast hier etwas vergessen deswegen der Error. Leider kann ich dir nicht sagen wo, da ich mich im bereich scripting nicht so gut auskenne.


    ShowPlayerDialog(playerid,DIALOG_AUTOHAUS,DIALOG_STYLE_MSGBOX,"Autoverkauf",string,"Ja","Nein");

    Bist du dir sicher das da "String" stehen muss?

  • Fehler durch schreiben in ein Filterscript behoben.


    Trotzdem stelle ich mir noch eine Frage. Sobald ich ein Auto kaufe. Trägt er meine ID ein und nicht mein Spielname. Was habe ich falsch gemacht ? Ich bin mal so frei und Poste den kompletten Code da dieser eh öffentlich zufinden ist.





    //Includes
    #include <a_samp>
    #include <ocmd>
    #include <sscanf>
    #include <a_mysql>



    //enums
    enum PlayerInfo{
    eingeloggt,
    level,
    pName,
    alevel,



    }





    enum carEnum{
    id_x,
    model,
    besitzer,
    Float:c_x,
    Float:c_y,
    Float:c_z,
    Float:c_r,
    pName
    }



    enum autohausEnum{
    Float:s_x,
    Float:s_y,
    Float:s_z,
    Float:s_r
    }



    enum autohauscarEnum{
    model,
    Float:c_x,
    Float:c_y,
    Float:c_z,
    Float:c_r,
    c_preis,
    ah_id,
    id_x
    }



    //Globale Variablen
    new dbhandle;
    new sInfo[MAX_PLAYERS][PlayerInfo];



    new cInfo[50][carEnum];
    new ahInfo[][autohausEnum] = {
    {125.7242,-170.1469,1.2838,177.7335},//id: 0 1. autohaus
    {189.8910,-263.3446,1.2829,180.6895}//id: 1 2. autohaus
    };
    new ahCars[][autohauscarEnum] = {
    {560,118.5637,-153.0834,1.2834,186.6475,50000,0},
    {411,106.3420,-158.7720,1.7527,257.3197,80000,0},
    {400,204.8894,-265.4756,1.2866,354.1406,10000,1}
    };



    //Farben
    #define COLOR_RED 0xFF0000FF



    //Dialoge




    #define DIALOG_AUTOHAUS 4



    //MySQL
    #define db_host "127.0.0.1"
    #define db_user "root"
    #define db_pass ""
    #define db_db "samp_db"



    //Forwards
    forward OnUserCheck(playerid);
    forward OnPasswordResponse(playerid);
    forward carSavedToDB(carid);
    forward OnPlayerCarsLoad(playerid);



    main()
    {



    }




    public OnGameModeInit()
    {
    SetGameModeText("MrMonat Tutorialmode");
    AddPlayerClass(1,199.0846,-150.0331,1.5781,359.1443,WEAPON_MP5,500,0,0,0,0);
    AddPlayerClass(2,199.0846,-150.0331,1.5781,359.1443,WEAPON_MP5,500,0,0,0,0);
    AddPlayerClass(3,199.0846,-150.0331,1.5781,359.1443,WEAPON_MP5,500,0,0,0,0);





    //Autos erstellen
    AddStaticVehicle(560,214.1196,-141.3710,1.3052,1.6804,-1,-1); //Sultan



    //Autoh?er laden
    for(new i=0; i<sizeof(ahCars); i++)
    {
    ahCars[i][id_x]=AddStaticVehicle(ahCars[i][model],ahCars[i][c_x],ahCars[i][c_y],ahCars[i][c_z],ahCars[i][c_r],-1,-1);
    }



    //MySQL
    dbhandle = mysql_connect(db_host,db_user,db_db,db_pass);
    return 1;
    }



    public OnGameModeExit()
    {
    mysql_close(dbhandle);
    return 1;
    }



    public OnPlayerRequestClass(playerid, classid)
    {
    SetPlayerPos(playerid,199.0846,-150.0331,1.5781);
    SetPlayerCameraPos(playerid, 199.2307,-143.8328,1.5781);
    SetPlayerCameraLookAt(playerid, 199.0846,-150.0331,1.5781);
    SetPlayerFacingAngle(playerid,359.1443);
    return 1;
    }



    public OnUserCheck(playerid)
    {



    return 1;
    }



    public OnPlayerConnect(playerid)
    {
    new nachricht[128];
    format(nachricht,sizeof(nachricht),"Du bist mit der ID %i verbunden.",playerid);
    SendClientMessage(playerid,COLOR_RED,nachricht);



    //Login/Register
    new name[MAX_PLAYER_NAME],query[128];
    GetPlayerName(playerid,name,sizeof(name));
    format(query,sizeof(query),"SELECT id FROM user WHERE users='%s'",name);
    mysql_function_query(dbhandle,query,true,"OnUserCheck","i",playerid);
    return 1;
    }



    savePlayer(playerid)
    {
    if(sInfo[playerid][eingeloggt]==0)return 1;
    //Speichern level,money
    new query[128];
    format(query,sizeof(query),"UPDATE user SET level='%i',money='%i',alevel='%i' WHERE id='%i'",sInfo[playerid][level],
    GetPlayerMoney(playerid),sInfo[playerid][alevel],sInfo[playerid][pName]);
    mysql_function_query(dbhandle,query,false,"","");
    return 1;
    }



    resetPlayer(playerid)
    {
    for(new i=0; i<sizeof(sInfo[]); i++)
    {
    sInfo[playerid][PlayerInfo:i]=0;
    }
    return 1;
    }



    public OnPlayerDisconnect(playerid, reason)
    {
    for(new i=0; i<sizeof(cInfo); i++)
    {
    if(cInfo[i][id_x]==0)continue;
    if(cInfo[i][besitzer]!=sInfo[playerid][pName])continue;
    GetVehiclePos(cInfo[i][id_x],cInfo[i][c_x],cInfo[i][c_y],cInfo[i][c_z]);
    GetVehicleZAngle(cInfo[i][id_x],cInfo[i][c_r]);
    new query[256];
    format(query,sizeof(query),"UPDATE autos SET x='%f',y='%f',z='%f',r='%f' WHERE id='%i'",cInfo[i][c_x],cInfo[i][c_y],cInfo[i][c_z],cInfo[i][c_r],cInfo[i][pName]);
    mysql_function_query(dbhandle,query,false,"","");
    DestroyVehicle(cInfo[i][id_x]);
    cInfo[i][id_x]=0;
    }
    savePlayer(playerid);
    resetPlayer(playerid);
    return 1;
    }



    public OnPlayerSpawn(playerid)
    { loadPlayerCars(playerid);
    return 1;
    }



    public OnPlayerDeath(playerid, killerid, reason)
    {
    return 1;
    }



    public OnVehicleSpawn(vehicleid)
    {
    return 1;
    }



    public OnVehicleDeath(vehicleid, killerid)
    {
    return 1;
    }



    public OnPlayerText(playerid, text[])
    {
    return 1;
    }



    public carSavedToDB(carid)
    {
    cInfo[carid][pName]=cache_insert_id(dbhandle);
    return 1;
    }



    saveCarToDB(playerid,carid)
    {
    new query[128];
    format(query,sizeof(query),"INSERT INTO autos (besitzer,model,x,y,z,r) VALUES ('%i','%i','%f','%f','%f','%f')",sInfo[playerid][pName],cInfo[carid][model],cInfo[carid][c_x],cInfo[carid][c_y],cInfo[carid][c_z],cInfo[carid][c_r]);
    mysql_function_query(dbhandle,query,true,"carSavedToDB","i",carid);
    return 1;
    }



    createPlayerCar(playerid,modelid,Float:x,Float:y,Float:z,Float:r)
    {
    for(new i=0; i<sizeof(cInfo); i++)
    {
    if(cInfo[i][id_x]!=0)continue;
    cInfo[i][besitzer]=sInfo[playerid][pName];
    cInfo[i][c_x]=x;
    cInfo[i][c_y]=y;
    cInfo[i][c_z]=z;
    cInfo[i][c_r]=r;
    cInfo[i][model]=modelid;
    cInfo[i][id_x] = CreateVehicle(modelid,x,y,z,r,-1,-1,-1);
    new string[128];
    format(string,sizeof(string),"Das Auto %i wurde erstellt.",i);
    SendClientMessageToAll(COLOR_RED,string);
    saveCarToDB(playerid,i);
    return 1;
    }
    return 1;
    }



    //Befehle




    ocmd:deletecar(playerid,params[])
    {
    if(!isAdmin(playerid,2))return SendClientMessage(playerid,COLOR_RED,"Dein Adminrang ist zu niedrig.");
    if(!IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid,COLOR_RED,"Du bist in keinem Fahrzeug.");
    DestroyVehicle(GetPlayerVehicleID(playerid));
    return 1;
    }



    ocmd:createcar(playerid,params[])
    {
    if(!isAdmin(playerid,2))return SendClientMessage(playerid,COLOR_RED,"Dein Adminrang ist zu niedrig.");
    new mID,pID;
    if(sscanf(params,"ui",pID,mID))return SendClientMessage(playerid,COLOR_RED,"INFO: /createcar [playerid] [model]");
    if(mID<400||mID>611)return SendClientMessage(playerid,COLOR_RED,"Ung??ges Model.");
    new Float:xc,Float:yc,Float:zc,Float:rc;
    GetPlayerPos(pID,xc,yc,zc);
    GetPlayerFacingAngle(pID,rc);
    createPlayerCar(pID,mID,xc,yc,zc,rc);
    return 1;
    }









    ocmd:pn(playerid,params[])
    {
    new pID,text[128];
    if(sscanf(params,"us[128]",pID,text))return SendClientMessage(playerid,COLOR_RED,"INFO: /pn [playerid] [text]");
    SendClientMessage(pID,COLOR_RED,text);
    return 1;
    }



    ocmd:setadmin(playerid,params[])
    {
    if(!isAdmin(playerid,3))return SendClientMessage(playerid,COLOR_RED,"Dein Adminrang ist zu niedrig.");
    new pID,a_level;
    if(sscanf(params,"ui",pID,a_level))return SendClientMessage(playerid,COLOR_RED,"INFO: /setadmin [playerid] [adminlevel]");
    sInfo[pID][alevel]=a_level;
    savePlayer(pID);
    SendClientMessage(pID,COLOR_RED,"Dein Adminrang wurde ge?ert.");
    SendClientMessage(playerid,COLOR_RED,"Du hast den Adminrang ge?ert.");
    return 1;
    }



    isAdmin(playerid,a_level)
    {
    if(sInfo[playerid][alevel]>=a_level)return 1;
    return 0;
    }



    ocmd:restart(playerid,params[])
    {
    if(!isAdmin(playerid,3))return SendClientMessage(playerid,COLOR_RED,"Dein Adminrang ist zu niedrig.");
    SendRconCommand("gmx");
    return 1;
    }



    ocmd:test(playerid,params[])
    {
    SendClientMessage(playerid,COLOR_RED,"Du hast /test eingegeben.");
    return 1;
    }




    public OnPlayerCommandText(playerid, cmdtext[])
    {
    return 0;
    }



    public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
    {
    return 1;
    }



    public OnPlayerExitVehicle(playerid, vehicleid)
    {
    return 1;
    }



    public OnPlayerStateChange(playerid, newstate, oldstate)
    {
    if(newstate==PLAYER_STATE_DRIVER)
    {
    new vID=GetPlayerVehicleID(playerid);
    for(new i=0; i<sizeof(ahCars); i++)
    {
    if(ahCars[i][id_x]!=vID)continue;
    //Verkaufsprozess
    SetPVarInt(playerid,"buyCarID",i);
    new string[256];
    format(string,sizeof(string),"M��en sie das Fahrzeug ff��i$ kaufen?",ahCars[i][c_preis]);
    ShowPlayerDialog(playerid,DIALOG_AUTOHAUS,DIALOG_STYLE_MSGBOX,"Autoverkauf",string,"Ja","Nein");
    break;
    }
    return 1;
    }
    return 1;
    }



    public OnPlayerEnterCheckpoint(playerid)
    {
    return 1;
    }



    public OnPlayerLeaveCheckpoint(playerid)
    {
    return 1;
    }



    public OnPlayerEnterRaceCheckpoint(playerid)
    {
    return 1;
    }



    public OnPlayerLeaveRaceCheckpoint(playerid)
    {
    return 1;
    }



    public OnRconCommand(cmd[])
    {
    return 1;
    }



    public OnPlayerRequestSpawn(playerid)
    {
    return 1;
    }



    public OnObjectMoved(objectid)
    {
    return 1;
    }



    public OnPlayerObjectMoved(playerid, objectid)
    {
    return 1;
    }



    public OnPlayerPickUpPickup(playerid, pickupid)
    {
    return 1;
    }



    public OnVehicleMod(playerid, vehicleid, componentid)
    {
    return 1;
    }



    public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
    {
    return 1;
    }



    public OnVehicleRespray(playerid, vehicleid, color1, color2)
    {
    return 1;
    }



    public OnPlayerSelectedMenuRow(playerid, row)
    {
    return 1;
    }



    public OnPlayerExitedMenu(playerid)
    {
    return 1;
    }



    public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
    {
    return 1;
    }



    public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
    {



    return 1;
    }



    public OnRconLoginAttempt(ip[], password[], success)
    {
    return 1;
    }



    public OnPlayerUpdate(playerid)
    {
    return 1;
    }



    public OnPlayerStreamIn(playerid, forplayerid)
    {
    return 1;
    }



    public OnPlayerStreamOut(playerid, forplayerid)
    {
    return 1;
    }



    public OnVehicleStreamIn(vehicleid, forplayerid)
    {
    return 1;
    }



    public OnVehicleStreamOut(vehicleid, forplayerid)
    {
    return 1;
    }





    getFreeCarID()
    {
    for(new i=0; i<sizeof(cInfo); i++)
    {
    if(cInfo[i][id_x]==0)return i;
    }
    return 0;
    }



    public OnPlayerCarsLoad(playerid)
    {
    new num_fields,num_rows;
    cache_get_data(num_rows,num_fields,dbhandle);
    if(!num_rows)return 1;
    for(new i=0; i<num_rows; i++)
    {
    new id=getFreeCarID();
    cInfo[id][model]=cache_get_field_content_int(i,"model",dbhandle);
    cInfo[id][besitzer]=cache_get_field_content_int(i,"besitzer",dbhandle);
    cInfo[id][c_x]=cache_get_field_content_float(i,"x",dbhandle);
    cInfo[id][c_y]=cache_get_field_content_float(i,"y",dbhandle);
    cInfo[id][c_z]=cache_get_field_content_float(i,"z",dbhandle);
    cInfo[id][c_r]=cache_get_field_content_float(i,"r",dbhandle);
    cInfo[id][pName]=cache_get_field_content_int(i,"id",dbhandle);
    cInfo[id][id_x]=CreateVehicle(cInfo[id][model],cInfo[id][c_x],cInfo[id][c_y],cInfo[id][c_z],cInfo[id][c_r],-1,-1,-1);
    }
    return 1;
    }



    loadPlayerCars(playerid)
    {
    new query[128];
    format(query,sizeof(query),"SELECT * FROM autos WHERE besitzer='%i'",sInfo[playerid][pName]);
    mysql_function_query(dbhandle,query,true,"OnPlayerCarsLoad","i",playerid);
    return 1;
    }



    public OnPasswordResponse(playerid)
    {
    return 1;
    }



    public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
    {
    if(dialogid==DIALOG_AUTOHAUS)
    {
    if(response)
    {
    //Autoverkauf
    new id=GetPVarInt(playerid,"buyCarID");
    if(GetPlayerMoney(playerid)<ahCars[id][c_preis])
    {
    SendClientMessage(playerid,COLOR_RED,"Du hast nicht gen��d Geld.");
    RemovePlayerFromVehicle(playerid);
    return 1;
    }
    GivePlayerMoney(playerid,-ahCars[id][c_preis]);
    createPlayerCar(playerid,ahCars[id][model],ahInfo[ahCars[id][ah_id]][s_x],ahInfo[ahCars[id][ah_id]][s_y],ahInfo[ahCars[id][ah_id]][s_z],ahInfo[ahCars[id][ah_id]][s_r]);
    SendClientMessage(playerid,COLOR_RED,"Herzlichen Gl��unsch zum neuen Auto");
    RemovePlayerFromVehicle(playerid);
    }
    else
    {
    RemovePlayerFromVehicle(playerid);
    SendClientMessage(playerid,COLOR_RED,"Dann eben nicht...");
    }
    return 1;
    }



    return 1;
    }







    2 Mal editiert, zuletzt von robbi2304 ()