CreateVehicle problem and Adminsystem Problem
#1

Hey gys, i have 2 problems...
my first:
I have a command to create a few vehicles that i defined before with CreateVehicle();
but the Cars are auto respawnin when they get destroyed. (i set the respawn_delay to -1)

second prob:
i have an admin script but no /register and /login system.
so i want to set the adminlevel of a person to 1,2 or 3 with /makeadmin [ID] [Level] and then save it into a file and when he types /login then the file should load, but it doesnt save i think.
maybe u can help...
CODE:
pawn Код:
CMD:makeadmin(playerid, params[])
{
    if (IsPlayerAdmin(playerid) || Player[playerid][ALevel] >= 3)
    {
        if (sscanf(params, "ud", params[0], params[1]))
        {
            SendClientMessage(playerid, RED, "SERVER: USAGE: /makeadmin [ID] [level]");
        }
        else if (params[0] == INVALID_PLAYER_ID)
        {
            SendClientMessage(playerid, RED, "SERVER: Ungьltige User-ID");
        }
        else
        {                          
            new file[128];
            new pname[56];
            new string[256];
           
            if (params[0] != playerid)
            {
                GetPlayerName(params[0], pname, sizeof(pname));
                format(string, sizeof(string), "*** Du hast %s zum Admin Stufe %d gemacht.", pname, params[1]);
                SendClientMessage(playerid, ORANGE, string);
               
                GetPlayerName(playerid, pname, sizeof(pname));
                format(string, sizeof(string), "*** %s hat dich zum Admin Stufe %d gemacht.", pname, params[1]);
                SendClientMessage(params[0], ORANGE, string);
            }
            else
            {
                format(string, sizeof(string), "*** Du hast dich selbst auf Adminlevel %d gesetzt.", params[1]);
                SendClientMessage(playerid, ORANGE, string);
            }
           
            SendClientMessage(params[0], YELLOW, "*** Du kannst dich jetzt mit /login [password] einloggen.");
            SendClientMessage(params[0], YELLOW, "*** Das Passwort kannst du bei dem Serverowner oder einem anderen Admin erfragen.");
   
            GetPlayerName(params[0], pname, sizeof(pname));
            format(file, sizeof(file), "%s.datei", pname);
            if (fexist(file))
            {
                SendClientMessage(playerid, RED, "SERVER: Der Spieler ist bereits Admin");
            }
            Player[playerid][ALevel] = params[1]
            dini_IntSet(file, "ALevel", Player[playerid][ALevel]);
            dini_IntSet(file, "Sprache", gSprache[playerid]);
        }
    }
    else
    {
        SendClientMessage(playerid, RED, "SERVER: Du bist nicht als Admin eingeloggt oder dein Adminlevel ist zu niedrig");
    }
    return 1;
}
// --Login- And RegisterCommands--

CMD:login(playerid, params[])
{
    if (!IsPlayerAdmin(playerid))
    {
        if (sscanf(params, "s", params[0]))
        {
            SendClientMessage(playerid, RED, "SERVER: USAGE: /login [password]");
        }
        else if (strcmp(params[0], gpassword, true))
        {
            SendClientMessage(playerid, RED, "SERVER: Falsches Passwort");
        }
        else
        {
            new file[128]
            new pname[56];
            new string[256];
           
            GetPlayerName(playerid, pname, sizeof(pname));
           
            SendClientMessage(playerid, YELLOW, "*** Du hast dich als Admin eingloggt.");
            SendClientMessage(playerid, YELLOW, "*** Dir stehen jetzt neue Adminbefehle zur Verfьgung.");
           
            format(file, sizeof(file), "%s.datei", pname);
           
            Player[playerid][Sprache] = dini_Int(file, "Sprache");
            Player[playerid][ALevel] = dini_Int(file, "ALevel");
           
            for (new i=0; i<MAX_PLAYERS; i++)
            {
                if (IsPlayerConnected(i))
                {
                    if (gSprache[playerid] == GERMAN)
                    {
                        format(string, sizeof(string), "*** %s hat sich als Admin eingeloggt.", pname);
                    }
                    else
                    {
                        format(string, sizeof(string), "*** %s logged in as Admin.", pname);
                    }
                    SendClientMessage(i, ORANGE, string);
                }
            }
        }
    }
    else
    {
        SendClientMessage(playerid, RED, "SERVER: Du bist bereits als Admin eingeloggt");
    }
    return 1;
}
Reply
#2

pawn Код:
if (fexist(file))
            {
                SendClientMessage(playerid, RED, "SERVER: Der Spieler ist bereits Admin");
            }
            else
            {
                dini_Create(file);
            }
            Player[params[0]][ALevel] = params[1];
            dini_IntSet(file, "ALevel", Player[params[0]][ALevel]);
            dini_IntSet(file, "Sprache", gSprache[params[0]]);
Reply
#3

okay i'll try this and edit my post with the result

//EDIT:
It works now, but i've got still the problem with my cars...
Reply
#4

PLEASE help
Reply
#5

Quote:
Originally Posted by тħeρяш
PLEASE help
Cars ALWAYS respawn after destroy.
Reply
#6

But
Quote:

The delay until the car is respawned without a driver in seconds (-1 to never respawn)

and i set it to -1.

And its still respawning
Reply
#7

Quote:
Originally Posted by тħeρяш
But
Quote:

The delay until the car is respawned without a driver in seconds (-1 to never respawn)

and i set it to -1.

And its still respawning
It will always respawn after destroyment, but if you leave it somewhere without getting it destroyed it will remain there.
Reply
#8

Oh, hmm...
Then What a function could i use?
(i also have 3 static vehicles)
Reply
#9

You need to save all created vehicles IDs

top of your script
pawn Код:
new CreatedVehicles[100];
command that creates vehicles
pawn Код:
for(new i=0; i < sizeof(CreatedVehicles); i++)
{
    if(CreatedVehicles[i] == 0)
    {
        CreatedVehicles[i] = CreateVehicle(...);
        break;
    }
}
pawn Код:
public OnVehicleSpawn(vehicleid)
{
    for(new i=0; i < sizeof(CreatedVehicles); i++)
    {
        if(CreatedVehicles[i] == vehicleid)
        {
            DestroyVehicle(vehicleid);
            CreatedVehicles[i] = 0;
            break;
        }
    }
    return 1;
}
Reply
#10

Thanks for that... i'll try it like this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)