Vcmp my new script

Started by QUITTED_VCMP, Feb 06, 2025, 11:04 AM

Previous topic - Next topic

QUITTED_VCMP

PLS ANY ONE TRY THIS SCRIPT AND TELL ME ITS WORK OR NOT ;D .Coz i quitted vcmp :'(
   
Script by: =PK=NO

        The script
 

#include <a_samp> // Include the VC:MP server library

#define MAX_PLAYERS 100

enum PlayerData {
    bool:IsRegistered,
    bool:IsLoggedIn,
    Password[129], // Hashed password
    Kills,
    Deaths,
    Money
};

new PlayerInfo[MAX_PLAYERS][PlayerData];

public OnPlayerConnect(playerid) {
    // Reset player data on connect
    PlayerInfo[playerid][IsRegistered] = false;
    PlayerInfo[playerid][IsLoggedIn] = false;
    PlayerInfo[playerid][Password] = "";
    PlayerInfo[playerid][Kills] = 0;
    PlayerInfo[playerid][Deaths] = 0;
    PlayerInfo[playerid][Money] = 0;

    // Load player data from file (if registered)
    LoadPlayerData(playerid);

    // Show registration/login dialog
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Welcome!", "Do you have an account?", "Login", "Register");
    return 1;
}

public OnPlayerDisconnect(playerid, reason) {
    // Save player data on disconnect
    SavePlayerData(playerid);
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
    if (dialogid == 1) {
        if (response) {
            // Login
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "Enter your password:", "Submit", "Cancel");
        } else {
            // Register
            ShowPlayerDialog(playerid, 3, DIALOG_STYLE_INPUT, "Register", "Choose a password:", "Submit", "Cancel");
        }
    } else if (dialogid == 2) {
        // Check login password
        if (strcmp(inputtext, PlayerInfo[playerid][Password], true) == 0) {
            PlayerInfo[playerid][IsLoggedIn] = true;
            SendClientMessage(playerid, 0x00FF00FF, "Login successful!");
        } else {
            SendClientMessage(playerid, 0xFF0000FF, "Incorrect password!");
        }
    } else if (dialogid == 3) {
        // Register new player
        if (strlen(inputtext) < 6) {
            SendClientMessage(playerid, 0xFF0000FF, "Password must be at least 6 characters long!");
            return 1;
        }

        PlayerInfo[playerid][IsRegistered] = true;
        PlayerInfo[playerid][Password] = inputtext; // In a real script, hash the password!
        PlayerInfo[playerid][IsLoggedIn] = true;
        SendClientMessage(playerid, 0x00FF00FF, "Registration successful!");
    }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason) {
    if (killerid != INVALID_PLAYER_ID) {
        PlayerInfo[killerid][Kills]++;
        PlayerInfo[playerid][Deaths]++;
        PlayerInfo[killerid][Money] += 100; // Reward for kill
        SendClientMessage(killerid, 0x00FF00FF, "You killed a player! +$100");
    }
    return 1;
}

LoadPlayerData(playerid) {
    // Load player data from a file (e.g., using INI or SQLite)
    // Example: Load kills, deaths, money, and password
    // This is a placeholder; implement file handling as needed
}

SavePlayerData(playerid) {
    // Save player data to a file (e.g., using INI or SQLite)
    // Example: Save kills, deaths, money, and password
    // This is a placeholder; implement file handling as needed
}




2.0 script
       



#include <a_samp> // Include the VC:MP server library

#define MAX_PLAYERS 100
#define MAX_ADMIN_LEVEL 3 // Define admin levels (e.g., 1 = Moderator, 2 = Admin, 3 = Super Admin)

enum PlayerData {
    bool:IsRegistered,
    bool:IsLoggedIn,
    Password[129], // Hashed password
    Kills,
    Deaths,
    Money,
    AdminLevel // Admin level (0 = Regular player, 1-3 = Admin levels)
};

new PlayerInfo[MAX_PLAYERS][PlayerData];

public OnPlayerConnect(playerid) {
    // Reset player data on connect
    PlayerInfo[playerid][IsRegistered] = false;
    PlayerInfo[playerid][IsLoggedIn] = false;
    PlayerInfo[playerid][Password] = "";
    PlayerInfo[playerid][Kills] = 0;
    PlayerInfo[playerid][Deaths] = 0;
    PlayerInfo[playerid][Money] = 0;
    PlayerInfo[playerid][AdminLevel] = 0; // Default to no admin privileges

    // Load player data from file (if registered)
    LoadPlayerData(playerid);

    // Show registration/login dialog
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Welcome!", "Do you have an account?", "Login", "Register");
    return 1;
}

public OnPlayerDisconnect(playerid, reason) {
    // Save player data on disconnect
    SavePlayerData(playerid);
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
    if (dialogid == 1) {
        if (response) {
            // Login
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "Enter your password:", "Submit", "Cancel");
        } else {
            // Register
            ShowPlayerDialog(playerid, 3, DIALOG_STYLE_INPUT, "Register", "Choose a password:", "Submit", "Cancel");
        }
    } else if (dialogid == 2) {
        // Check login password
        if (strcmp(inputtext, PlayerInfo[playerid][Password], true) == 0) {
            PlayerInfo[playerid][IsLoggedIn] = true;
            SendClientMessage(playerid, 0x00FF00FF, "Login successful!");
        } else {
            SendClientMessage(playerid, 0xFF0000FF, "Incorrect password!");
        }
    } else if (dialogid == 3) {
        // Register new player
        if (strlen(inputtext) < 6) {
            SendClientMessage(playerid, 0xFF0000FF, "Password must be at least 6 characters long!");
            return 1;
        }

        PlayerInfo[playerid][IsRegistered] = true;
        PlayerInfo[playerid][Password] = inputtext; // In a real script, hash the password!
        PlayerInfo[playerid][IsLoggedIn] = true;
        SendClientMessage(playerid, 0x00FF00FF, "Registration successful!");
    }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason) {
    if (killerid != INVALID_PLAYER_ID) {
        PlayerInfo[killerid][Kills]++;
        PlayerInfo[playerid][Deaths]++;
        PlayerInfo[killerid][Money] += 100; // Reward for kill
        SendClientMessage(killerid, 0x00FF00FF, "You killed a player! +$100");
    }
    return 1;
}

LoadPlayerData(playerid) {
    // Load player data from a file (e.g., using INI or SQLite)
    // Example: Load kills, deaths, money, password, and admin level
    // This is a placeholder; implement file handling as needed
}

SavePlayerData(playerid) {
    // Save player data to a file (e.g., using INI or SQLite)
    // Example: Save kills, deaths, money, password, and admin level
    // This is a placeholder; implement file handling as needed
}

// Admin commands
public OnPlayerCommandText(playerid, cmdtext[]) {
    new cmd[256], idx;
    cmd = strtok(cmdtext, idx);

    if (strcmp(cmd, "/kick", true) == 0) {
        if (PlayerInfo[playerid][AdminLevel] < 1) {
            SendClientMessage(playerid, 0xFF0000FF, "You do not have permission to use this command!");
            return 1;
        }

        new targetid, reason[128];
        targetid = strval(strtok(cmdtext, idx));
        reason = strtok(cmdtext, idx);

        if (!IsPlayerConnected(targetid)) {
            SendClientMessage(playerid, 0xFF0000FF, "Player is not connected!");
            return 1;
        }

        if (strlen(reason) == 0) {
            SendClientMessage(playerid, 0xFF0000FF, "Usage: /kick <playerid> <reason>");
            return 1;
        }

        Kick(targetid);
        SendClientMessageToAll(0xFF0000FF, sprintf("%s has been kicked by an admin. Reason: %s", GetPlayerName(targetid), reason));
        return 1;
    }

    if (strcmp(cmd, "/ban", true) == 0) {
        if (PlayerInfo[playerid][AdminLevel] < 2) {
            SendClientMessage(playerid, 0xFF0000FF, "You do not have permission to use this command!");
            return 1;
        }

        new targetid, reason[128];
        targetid = strval(strtok(cmdtext, idx));
        reason = strtok(cmdtext, idx);

        if (!IsPlayerConnected(targetid)) {
            SendClientMessage(playerid, 0xFF0000FF, "Player is not connected!");
            return 1;
        }

        if (strlen(reason) == 0) {
            SendClientMessage(playerid, 0xFF0000FF, "Usage: /ban <playerid> <reason>");
            return 1;
        }

        Ban(targetid);
        SendClientMessageToAll(0xFF0000FF, sprintf("%s has been banned by an admin. Reason: %s", GetPlayerName(targetid), reason));
        return 1;
    }

    if (strcmp(cmd, "/givemoney", true) == 0) {
        if (PlayerInfo[playerid][AdminLevel] < 3) {
            SendClientMessage(playerid, 0xFF0000FF, "You do not have permission to use this command!");
            return 1;
        }

        new targetid, amount;
        targetid = strval(strtok(cmdtext, idx));
        amount = strval(strtok(cmdtext, idx));

        if (!IsPlayerConnected(targetid)) {
            SendClientMessage(playerid, 0xFF0000FF, "Player is not connected!");
            return 1;
        }

        if (amount <= 0) {
            SendClientMessage(playerid, 0xFF0000FF, "Usage: /givemoney <playerid> <amount>");
            return 1;
        }

        PlayerInfo[targetid][Money] += amount;
        SendClientMessage(targetid, 0x00FF00FF, sprintf("You have received $%d from an admin.", amount));
        SendClientMessage(playerid, 0x00FF00FF, sprintf("You have given $%d to %s.", amount, GetPlayerName(targetid)));
        return 1;
    }

    if (strcmp(cmd, "/tp", true) == 0) {
        if (PlayerInfo[playerid][AdminLevel] < 1) {
            SendClientMessage(playerid, 0xFF0000FF, "You do not have permission to use this command!");
            return 1;
        }

        new targetid;
        targetid = strval(strtok(cmdtext, idx));

        if (!IsPlayerConnected(targetid)) {
            SendClientMessage(playerid, 0xFF0000FF, "Player is not connected!");
            return 1;
        }

        new Float:x, Float:y, Float:z;
        GetPlayerPos(targetid, x, y, z);
        SetPlayerPos(playerid, x, y, z);
        SendClientMessage(playerid, 0x00FF00FF, sprintf("You have teleported to %s.", GetPlayerName(targetid)));
        return 1;
    }

    if (strcmp(cmd, "/setadmin", true) == 0) {
        if (PlayerInfo[playerid][AdminLevel] < 3) {
            SendClientMessage(playerid, 0xFF0000FF, "You do not have permission to use this command!");
            return 1;
        }

        new targetid, level;
        targetid = strval(strtok(cmdtext, idx));
        level = strval(strtok(cmdtext, idx));

        if (!IsPlayerConnected(targetid)) {
            SendClientMessage(playerid, 0xFF0000FF, "Player is not connected!");
            return 1;
        }

        if (level < 0 || level > MAX_ADMIN_LEVEL) {
            SendClientMessage(playerid, 0xFF0000FF, "Invalid admin level!");
            return 1;
        }

        PlayerInfo[targetid][AdminLevel] = level;
        SendClientMessage(playerid, 0x00FF00FF, sprintf("You have set %s's admin level to %d.", GetPlayerName(targetid), level));
        SendClientMessage(targetid, 0x00FF00FF, sprintf("Your admin level has been set to %d by an admin.", level));
        return 1;
    }

    return 0;
}

QUITTED_VCMP

Is this working ???

Adrenaline

Can you upload the full server? I mean with the plugins and the rest to run the server locally?

KazamaOp

PK NO . Why You Quit :(

QUITTED_VCMP

Quote from: Adrenaline on Feb 07, 2025, 02:56 AMCan you upload the full server? I mean with the plugins and the rest to run the server locally?

I'll try bro

ToyDragon

Hello, I don't know much about it, but your script looks more like C + + or java, not the common Java language of vcmp, so I guess if you want to run this script, you need other plugin support, and I noticed that most of the functions are not official events of vcmp, and some of them are similar to letting the server-side script display GUI to the client?  ?  In my opinion, this seems to need the support of client script. If there is no support of client script, the server should not be able to display GUI directly to the client. Therefore, based on the above situation, I think this script should not run. I come from China, so my English may not be very good. Please be tolerant.