Problem with Loading Weapon Y_ini in Gamemode
#1

Please help to solve my problem..
The problem is When we login with new account/login with registered account.. player will automatic get weapon.. in the script i dont give any GivePlayerWeapon. How to solve this? Wrong with OnPlayerConnect/onPlayerDisconnect/LoadWeapon?


#NO STEAL PLEASE
Код HTML:
//includes
#include <a_samp>
#include <zcmd>
#include <colors>
#include <mSelection>
#include <YSI\y_ini>
#include <sscanf2>

//defines
#define register 1
#define login 2
#define UserPath "/%s.ini"
#define PATH "/%s.ini"

native WP_Hash(buffer[],len,const str[]);

enum PlayerInfo
{
    Pass[129], //User's password
    Adminlevel, //User's admin level
    VIPlevel, //User's vip level
    Money, //User's money
    Scores, //User's scores
    Kills, //User's kills
    Deaths //User's deaths
}

enum wInfo {

// Weapons
    Weapon1,
    Weapon2,
    Weapon3,
    Weapon4,
    Weapon5,
    Weapon6,
    Weapon7,
    Weapon8,
    Weapon9,
    Weapon10,
    Weapon11,
    Weapon12,

//Ammo
    Ammo1,
    Ammo2,
    Ammo3,
    Ammo4,
    Ammo5,
    Ammo6,
    Ammo7,
    Ammo8,
    Ammo9,
    Ammo10,
    Ammo11,
    Ammo12,
}

new WeaponInfo[MAX_PLAYERS][wInfo];
new pInfo[MAX_PLAYERS][PlayerInfo];
new Float:posX[MAX_PLAYERS];
new Float:posY[MAX_PLAYERS];
new Float:posZ[MAX_PLAYERS];
new Float:posA[MAX_PLAYERS];
new Interior[MAX_PLAYERS];
new VirtualWorld[MAX_PLAYERS];
new Saved[MAX_PLAYERS];
new Text:ShadowsRandom;
new vehiclelist = mS_INVALID_LISTID;
new skinlist = mS_INVALID_LISTID;
new weaponlist = mS_INVALID_LISTID;
new DropLimit = 4; // above
new DeleteTime = 20;

forward DeletePickup(pickupid);
forward RandomMessage();
forward loadaccount_user(playerid, name[], value[]);
forward DropPlayerWeapons(playerid);

new RandomMessages[][] =
{
    "Menggunakan Program ilegal akan kami BANNED!       /skin(kostum) /vehicle(kendaraan) /weapon(senjata)",
    "No SARA No JUNK No SPAWNKILL, Just PLAY AND FUN!   /skin(kostum) /vehicle(kendaraan) /weapon(senjata)",
    "Server Ini Masih dalam Keadaan BETA!               /skin(kostum) /vehicle(kendaraan) /weapon(senjata)",
    "Dibutuhkan ADMIN Segera, Hub: DheWardhana(OWNER)!  /skin(kostum) /vehicle(kendaraan) /weapon(senjata)"
};

main()
{
    print("\n----------------------------------");
    print(" Stepn'One GAMEMODE Script's");
    print(" Weapon System: ADDED!");
    print(" Vehicle System: ADDED!");
    print(" Skin System: ADDED!");
    print(" Admin System: NOTYET!");
    print("----------------------------------\n");
}

public OnGameModeInit()
{
    SetNameTagDrawDistance(40.0);
    EnableStuntBonusForAll(0);
    SetWeather(2);
    SetWorldTime(11);

    vehiclelist = LoadModelSelectionMenu("vehicle.txt");
    skinlist = LoadModelSelectionMenu("skins.txt");
    weaponlist = LoadModelSelectionMenu("weapons.txt");

    ShowPlayerMarkers(1);
    ShowNameTags(1);

    SetTimer("RandomMessage",3000,1);
    ShadowsRandom = TextDrawCreate(18.000000,428.000000,"Selamat datang di Step'nOne SAMP                   /skin(kostum) /vehicle(kendaraan) /weapon(senjata)");
    TextDrawAlignment(ShadowsRandom,0);
    TextDrawBackgroundColor(ShadowsRandom,0x000000ff);
    TextDrawFont(ShadowsRandom,2);
    TextDrawLetterSize(ShadowsRandom,0.199999,0.899999);
    TextDrawColor(ShadowsRandom,0xffffffff);
    TextDrawSetOutline(ShadowsRandom,1);
    TextDrawSetProportional(ShadowsRandom,1);
    TextDrawSetShadow(ShadowsRandom,1);
    SetGameModeText("STEPNONE GAMEMODE!");

    for(new s = 0; s < 300; s++)
    {
        if(IsInvalidSkin(s)) continue;
        else AddPlayerClass(s, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    }
    return 1;
}

stock IsInvalidSkin(skinid)
{
    #define MAX_BAD_SKINS  15
    if(skinid > 310) return true;
    new badSkins[MAX_BAD_SKINS] = {
        3, 4, 5, 6, 8, 42, 65, 74, 86,
        119, 149, 208, 273, 289, 0
    };
    for (new i = 0; i < MAX_BAD_SKINS; i++)
    {
      if (skinid == badSkins[i]) return true;
    }
    return false;
}

public OnGameModeExit()
{
 return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid,1984.4445,157.9501,55.9384);
    SetPlayerCameraPos(playerid,1984.4445,160.9501,55.9384);
    SetPlayerCameraLookAt(playerid,1984.4445,157.9501,55.9384);
    SetPlayerFacingAngle(playerid,0.0);
    return 1;
}

public OnPlayerConnect(playerid)
{
    posX[playerid] = 0.000000, posY[playerid] = 0.000000, posZ[playerid] = 0.000000;
    posA[playerid] = 0.000000, Interior[playerid] = 0, VirtualWorld[playerid] = 0;
    Saved[playerid] = 0;
    new name[MAX_PLAYER_NAME]; //Making a new variable called 'name'. name[MAX_PLAYER_NAME] is created so we can use it to get player's name.
    GetPlayerName(playerid,name,sizeof(name)); //Get player's name
    if(fexist(Path(playerid))) /* Check if the connected user is registered or not. fexist stands for file exist. So if file exist in the files(Path(playerid)),*/
    {// then
        INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid); //Will load user's data using INI_Parsefile.
        ShowPlayerDialog(playerid,login,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account","Login","Quit");/*A dialog with input style will appear so you can insert your password to login.*/
    }
    else //If the connected user is not registered,
    {//then we will 'force' him to register :)
        ShowPlayerDialog(playerid,register,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.","Register","Quit");
        return 1;
    }
    if(!fexist(pWeaponSave(playerid)))
    {
        new INI:wfile = INI_Open(pWeaponSave(playerid));
                    //  Weapon Create
        INI_WriteInt(wfile, "Weapon1", 0);
        INI_WriteInt(wfile, "Weapon2", 0);
        INI_WriteInt(wfile, "Weapon3", 0);
        INI_WriteInt(wfile, "Weapon4", 0);
        INI_WriteInt(wfile, "Weapon5", 0);
        INI_WriteInt(wfile, "Weapon6", 0);
        INI_WriteInt(wfile, "Weapon7", 0);
        INI_WriteInt(wfile, "Weapon8", 0);
        INI_WriteInt(wfile, "Weapon9", 0);
        INI_WriteInt(wfile, "Weapon10", 0);
        INI_WriteInt(wfile, "Weapon11", 0);
        INI_WriteInt(wfile, "Weapon12", 0);
                    // Ammo Create
        INI_WriteInt(wfile, "Ammo1", 0);
        INI_WriteInt(wfile, "Ammo2", 0);
        INI_WriteInt(wfile, "Ammo3", 0);
        INI_WriteInt(wfile, "Ammo4", 0);
        INI_WriteInt(wfile, "Ammo5", 0);
        INI_WriteInt(wfile, "Ammo6", 0);
        INI_WriteInt(wfile, "Ammo7", 0);
        INI_WriteInt(wfile, "Ammo8", 0);
        INI_WriteInt(wfile, "Ammo9", 0);
        INI_WriteInt(wfile, "Ammo10", 0);
        INI_WriteInt(wfile, "Ammo11", 0);
        INI_WriteInt(wfile, "Ammo12", 0);
        INI_Close(wfile);
        INI_ParseFile(pWeaponSave(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
    }
    else if(fexist(pWeaponSave(playerid)))
    {
        INI_ParseFile(pWeaponSave(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    GetPlayerWeaponData(playerid, 1, WeaponInfo[playerid][Weapon1], WeaponInfo[playerid][Ammo1]);
    GetPlayerWeaponData(playerid, 2, WeaponInfo[playerid][Weapon2], WeaponInfo[playerid][Ammo2]);
    GetPlayerWeaponData(playerid, 3, WeaponInfo[playerid][Weapon3], WeaponInfo[playerid][Ammo3]);
    GetPlayerWeaponData(playerid, 4, WeaponInfo[playerid][Weapon4], WeaponInfo[playerid][Ammo4]);
    GetPlayerWeaponData(playerid, 5, WeaponInfo[playerid][Weapon5], WeaponInfo[playerid][Ammo5]);
    GetPlayerWeaponData(playerid, 6, WeaponInfo[playerid][Weapon6], WeaponInfo[playerid][Ammo6]);
    GetPlayerWeaponData(playerid, 7, WeaponInfo[playerid][Weapon7], WeaponInfo[playerid][Ammo7]);
    GetPlayerWeaponData(playerid, 8, WeaponInfo[playerid][Weapon8], WeaponInfo[playerid][Ammo8]);
    GetPlayerWeaponData(playerid, 9, WeaponInfo[playerid][Weapon9], WeaponInfo[playerid][Ammo9]);
    GetPlayerWeaponData(playerid, 10, WeaponInfo[playerid][Weapon10], WeaponInfo[playerid][Ammo10]);
    GetPlayerWeaponData(playerid, 11, WeaponInfo[playerid][Weapon11], WeaponInfo[playerid][Ammo11]);
    GetPlayerWeaponData(playerid, 12, WeaponInfo[playerid][Weapon12], WeaponInfo[playerid][Ammo12]);

    new INI:file = INI_Open(Path(playerid)); //will open their file
    INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
    INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]); //If you've set his/her admin level, then his/her admin level will be saved inside of his/her account
    INI_WriteInt(file,"VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
    INI_WriteInt(file,"Money",GetPlayerMoney(playerid));//We will save his money inside of his account
    INI_WriteInt(file,"Scores",GetPlayerScore(playerid));//We will save his score inside of his account
    INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);//As explained above
    INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);//As explained above

    new INI:wfile = INI_Open(pWeaponSave(playerid));
    if(fexist(pWeaponSave(playerid)))
    {
        //      Weapon Save
        INI_WriteInt(wfile, "Weapon1", WeaponInfo[playerid][Weapon1]);
        INI_WriteInt(wfile, "Weapon2", WeaponInfo[playerid][Weapon2]);
        INI_WriteInt(wfile, "Weapon3", WeaponInfo[playerid][Weapon3]);
        INI_WriteInt(wfile, "Weapon4", WeaponInfo[playerid][Weapon4]);
        INI_WriteInt(wfile, "Weapon5", WeaponInfo[playerid][Weapon5]);
        INI_WriteInt(wfile, "Weapon6", WeaponInfo[playerid][Weapon6]);
        INI_WriteInt(wfile, "Weapon7", WeaponInfo[playerid][Weapon7]);
        INI_WriteInt(wfile, "Weapon8", WeaponInfo[playerid][Weapon8]);
        INI_WriteInt(wfile, "Weapon9", WeaponInfo[playerid][Weapon9]);
        INI_WriteInt(wfile, "Weapon10", WeaponInfo[playerid][Weapon10]);
        INI_WriteInt(wfile, "Weapon11", WeaponInfo[playerid][Weapon11]);
        INI_WriteInt(wfile, "Weapon12", WeaponInfo[playerid][Weapon12]);
                    //      Ammo Save
        INI_WriteInt(wfile, "Ammo1", WeaponInfo[playerid][Ammo1]);
        INI_WriteInt(wfile, "Ammo2", WeaponInfo[playerid][Ammo2]);
        INI_WriteInt(wfile, "Ammo3", WeaponInfo[playerid][Ammo3]);
        INI_WriteInt(wfile, "Ammo4", WeaponInfo[playerid][Ammo4]);
        INI_WriteInt(wfile, "Ammo5", WeaponInfo[playerid][Ammo5]);
        INI_WriteInt(wfile, "Ammo6", WeaponInfo[playerid][Ammo6]);
        INI_WriteInt(wfile, "Ammo7", WeaponInfo[playerid][Ammo7]);
        INI_WriteInt(wfile, "Ammo8", WeaponInfo[playerid][Ammo8]);
        INI_WriteInt(wfile, "Ammo9", WeaponInfo[playerid][Ammo9]);
        INI_WriteInt(wfile, "Ammo10", WeaponInfo[playerid][Ammo10]);
        INI_WriteInt(wfile, "Ammo11", WeaponInfo[playerid][Ammo11]);
        INI_WriteInt(wfile, "Ammo12", WeaponInfo[playerid][Ammo12]);
        INI_Close(wfile);
    }
    return 1;
}

public OnPlayerSpawn(playerid)
{
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon1], WeaponInfo[playerid][Ammo1]);
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon2], WeaponInfo[playerid][Ammo2]);
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon3], WeaponInfo[playerid][Ammo3]);
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon4], WeaponInfo[playerid][Ammo4]);
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon5], WeaponInfo[playerid][Ammo5]);
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon6], WeaponInfo[playerid][Ammo6]);
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon7], WeaponInfo[playerid][Ammo7]);
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon8], WeaponInfo[playerid][Ammo8]);
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon9], WeaponInfo[playerid][Ammo9]);
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon10], WeaponInfo[playerid][Ammo10]);
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon11], WeaponInfo[playerid][Ammo11]);
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon12], WeaponInfo[playerid][Ammo12]);
    new PlayerName[MAX_PLAYER_NAME],
    string[128];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    format(string, sizeof(string), "%s Telah Respawn.", PlayerName);
    SendClientMessageToAll(COLOR_RED, string);
    TextDrawShowForPlayer(playerid, ShadowsRandom);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	DropPlayerWeapons(playerid);
    pInfo[killerid][Kills]++;//Will give 1 kill to killer and it will be saved inside of his/her account
    pInfo[playerid][Deaths]++;
    SendDeathMessage(killerid, playerid, reason);
    return 1;
}

public OnPlayerModelSelection(playerid, response, listid, modelid)
{
    if(listid == vehiclelist)
    {
        if(response)
        {
            SendClientMessage(playerid, 0xFF0000FF, "Kendaraan Muncul!");
            new Float:pos[3]; GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
            CreateVehicle(modelid, pos[0] + 2.5, pos[1], pos[2] + 2.5, 0.0, random(128), random(128), -1);
        }
        else SendClientMessage(playerid, 0xFF0000FF, "Mematalkan Pemilihan Kendaraan");
        return 1;
    }
    if(listid == skinlist)
    {
        if(response)
        {
            SendClientMessage(playerid, 0xFF0000FF, "Skin Terganti!");
            SetPlayerSkin(playerid, modelid);
        }
        else SendClientMessage(playerid, 0xFF0000FF, "Membatalkan Pemilihan Skin");
        return 1;
    }
    if(listid == weaponlist)
    {
        if(modelid==331) //1 knuckle
       {
        if(GetPlayerMoney(playerid) <450) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
        SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Brass Knuckles dengan $450");
        GivePlayerMoney(playerid, -450);
        GivePlayerWeapon(playerid, 1, 9999);
       }
        if(modelid==335) //4 pisau
       {
        if(GetPlayerMoney(playerid) <750) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
        SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Knife dengan $750");
        GivePlayerMoney(playerid, -750);
        GivePlayerWeapon(playerid, 4, 9999);
       }
        if(modelid==339) //8 katana
       {
        if(GetPlayerMoney(playerid) <1000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
        SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Katana dengan $1000");
        GivePlayerMoney(playerid, -1000);
        GivePlayerWeapon(playerid, 8, 9999);
       }
        if(modelid==346) //22 9mm
       {
        if(GetPlayerMoney(playerid) <3500) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
        SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Pistol 9mm dengan $3500");
        GivePlayerMoney(playerid, -3500);
        GivePlayerWeapon(playerid, 22, 350);
       }
        if(modelid==347) //23 silenced 9mm
       {
        if(GetPlayerMoney(playerid) <5000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
        SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Pistol Silenced 9mm dengan $5000");
        GivePlayerMoney(playerid, -5000);
        GivePlayerWeapon(playerid, 23, 350);
       }
        if(modelid==348) //24 Deagle
       {
        if(GetPlayerMoney(playerid) <8000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
        SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Deagle Pistol dengan $8000");
        GivePlayerMoney(playerid, -8000);
        GivePlayerWeapon(playerid, 24, 200);
       }
        if(modelid==349) //25 Shotgun
       {
        if(GetPlayerMoney(playerid) <6000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
        SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Shotgun dengan $6000");
        GivePlayerMoney(playerid, -6000);
        GivePlayerWeapon(playerid, 25, 80);
       }
        if(modelid==350) //26 Sawnoff Shotgun
       {
        if(GetPlayerMoney(playerid) <8000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
        SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Sawnoff Shotgun dengan $8000");
        GivePlayerMoney(playerid, -8000);
        GivePlayerWeapon(playerid, 26, 80);
       }
        if(modelid==351) //27 auto Shotgun
       {
        if(GetPlayerMoney(playerid) <10000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
        SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Combat Shotgun dengan $10000");
        GivePlayerMoney(playerid, -10000);
        GivePlayerWeapon(playerid, 27, 80);
       }
        if(modelid==352)
       {
        if(GetPlayerMoney(playerid) <7500) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
        SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Uzi dengan $5000");
        GivePlayerMoney(playerid, -7500);
        GivePlayerWeapon(playerid, 28, 650);
       }
        if(modelid==356)
       {
        if(GetPlayerMoney(playerid) <22500) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
        SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli M4 Maverick dengan $22500");
        GivePlayerMoney(playerid, -22500);
        GivePlayerWeapon(playerid, 31, 400);
       }
        if(modelid==357)
       {
        if(GetPlayerMoney(playerid) <15000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
        SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Gun Rifle dengan $15000");
        GivePlayerMoney(playerid, -15000);
        GivePlayerWeapon(playerid, 33, 50);
       }
        if(modelid==358)
       {
        if(GetPlayerMoney(playerid) <17500) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
        SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Sniper Rifle dengan $17500");
        GivePlayerMoney(playerid, -17500);
        GivePlayerWeapon(playerid, 34, 40);
       }
        if(modelid==359)
       {
        if(GetPlayerMoney(playerid) <100000) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
        SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli RPG dengan $100000");
        GivePlayerMoney(playerid, -100000);
        GivePlayerWeapon(playerid, 35, 10);
       }
        if(modelid==367)
       {
        if(GetPlayerMoney(playerid) <7500) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
        SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Canon 1DX dengan $7500");
        GivePlayerMoney(playerid, -7500);
        GivePlayerWeapon(playerid, 43, 1000);
       }
        if(modelid==371)
       {
        if(GetPlayerMoney(playerid) <600) return SendClientMessage(playerid, COLOR_RED, "Uang Anda Tidak Mencukupi!");
        SendClientMessage(playerid, COLOR_BLUE, "Kamu telah membeli Parachute dengan $6000");
        GivePlayerMoney(playerid, -6000);
        GivePlayerWeapon(playerid, 46, 1);
       }
     }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == register) //If dialog id is a register dialog
    {//then
        if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
        if(response) //if they clicked the first button "Register"
        {//then
            if(!strlen(inputtext)) //If they didn't enter any password
            {// then we will tell to them to enter the password to register
                ShowPlayerDialog(playerid,register,DIALOG_STYLE_INPUT,"Mendaftar","Selamat datang! Akun ini belum terdaftar.\nMasukkan Password untuk membuar Akun.\nTolong masukkan password!","Register","Quit");
                return 1;
            }
            //If they have entered a correct password for his/her account...
            new hashpass[129]; //Now we will create a new variable to hash his/her password
            WP_Hash(hashpass,sizeof(hashpass),inputtext);//We will use whirlpool to hash their inputted text
            new INI:file = INI_Open(Path(playerid)); // we will open a new file for them to save their account inside of Scriptfiles/Users folder
            INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
            INI_WriteString(file,"Password",hashpass);//This will write a hashed password into user's account
            INI_WriteInt(file,"AdminLevel",0); //Write an integer inside of user's account called "AdminLevel". We will set his level to 0 after he registered.
            INI_WriteInt(file,"VIPLevel",0);//As explained above
            INI_WriteInt(file,"Money",0);//Write an integer inside of user's account called "Money". We will set their money to 0 after he registered
            INI_WriteInt(file,"Scores",0);//Write an integer inside of user's account called "Scores". We will set their score to 0 after he registered
            INI_WriteInt(file,"Kills",0);//As explained above
            INI_WriteInt(file,"Deaths",0);//As explained above
            INI_Close(file);//Now after we've done saving their data, we now need to close the file
            SendClientMessage(playerid,-1,"Anda sudah terdaftar dengan baik!");//Tell to them that they have successfully registered a new account
            return 1;
        }
    }
    if(dialogid == login) //If dialog id is a login dialog
    {//then
        if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
        if(response) //if they clicked the first button "Register"
        {//then
            new hashpass[129]; //Will create a new variable to hash his/her password
            WP_Hash(hashpass,sizeof(hashpass),inputtext); //Will hash inputted password
            if(!strcmp(hashpass, pInfo[playerid][Pass], false)) //If they have insert their correct password
            {//then
                INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);//We will load his account's data from user's path
                SetPlayerScore(playerid,pInfo[playerid][Scores]);//We will get their score inside of his user's account and we will set it here
                GivePlayerMoney(playerid,pInfo[playerid][Money]);//As explained above
                SendClientMessage(playerid,-1,"Selamat datang kembali! kamu telah berhasil masuk!");//Tell them that they've successfully logged in
            }
            else //If they've entered an incorrect password
            {//then
                ShowPlayerDialog(playerid,login,DIALOG_STYLE_INPUT,"Masuk","Selamat datang kembali. Akun ini telah terdaftar. \nMasukkan passwordmu untuk masuk ke akun anda!.\nPassword salah!","Masuk","Keluar");//We will tell to them that they've entered an incorrect password
                return 1;
            }
        }
    }
    return 1;
}

public loadaccount_user(playerid, name[], value[])
{
    INI_String("Password", pInfo[playerid][Pass],129); /*we will use INI_String to load user's password.
    ("Password",.. will load user's password inside of user's path. 'pInfo[playerid][Pass]',...We have defined our user's variable above called, pInfo. Now it's time to use it here to load user's password. '129',... 129 is a length of a hashed user's password. Whirlpool will hash 128 characters + NULL*/
    INI_Int("AdminLevel",pInfo[playerid][Adminlevel]);/*We will use INI_Int to load user's admin level. INI_Int stands for INI_Integer. This load an admin level. */
    INI_Int("VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
    INI_Int("Money",pInfo[playerid][Money]); //As explained above
    INI_Int("Scores",pInfo[playerid][Scores]);//As explained above
    INI_Int("Kills",pInfo[playerid][Kills]);//As explained above
    INI_Int("Deaths",pInfo[playerid][Deaths]);//As explained above
    INI_Int("Weapon1", WeaponInfo[playerid][Weapon1]);
    INI_Int("Weapon2", WeaponInfo[playerid][Weapon2]);
    INI_Int("Weapon3", WeaponInfo[playerid][Weapon3]);
    INI_Int("Weapon4", WeaponInfo[playerid][Weapon4]);
    INI_Int("Weapon5", WeaponInfo[playerid][Weapon5]);
    INI_Int("Weapon6", WeaponInfo[playerid][Weapon6]);
    INI_Int("Weapon7", WeaponInfo[playerid][Weapon7]);
    INI_Int("Weapon8", WeaponInfo[playerid][Weapon8]);
    INI_Int("Weapon9", WeaponInfo[playerid][Weapon9]);
    INI_Int("Weapon10", WeaponInfo[playerid][Weapon10]);
    INI_Int("Weapon11", WeaponInfo[playerid][Weapon11]);
    INI_Int("Weapon12", WeaponInfo[playerid][Weapon12]);
        // Load Ammo
    INI_Int("Ammo1", WeaponInfo[playerid][Ammo1]);
    INI_Int("Ammo2", WeaponInfo[playerid][Ammo2]);
    INI_Int("Ammo3", WeaponInfo[playerid][Ammo3]);
    INI_Int("Ammo4", WeaponInfo[playerid][Ammo4]);
    INI_Int("Ammo5", WeaponInfo[playerid][Ammo5]);
    INI_Int("Ammo6", WeaponInfo[playerid][Ammo6]);
    INI_Int("Ammo7", WeaponInfo[playerid][Ammo7]);
    INI_Int("Ammo8", WeaponInfo[playerid][Ammo8]);
    INI_Int("Ammo9", WeaponInfo[playerid][Ammo9]);
    INI_Int("Ammo10", WeaponInfo[playerid][Ammo10]);
    INI_Int("Ammo11", WeaponInfo[playerid][Ammo11]);
    INI_Int("Ammo12", WeaponInfo[playerid][Ammo12]);
    return 1;
}

public DropPlayerWeapons(playerid)
{
    new playerweapons[13][2];
    new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid, x, y, z);//here gets your position..!

    for(new i=0; i<13; i++)
    {
        GetPlayerWeaponData(playerid, i, playerweapons[i][0], playerweapons[i][1]);
        new model = GetWeaponType(playerweapons[i][0]);// this to get, what weapons are you using in the moment !
        new times = floatround(playerweapons[i][1]/10.0001);
        new Float:X = x + (random(3) - random(3));
        new Float:Y = y + (random(3) - random(3));
        if(playerweapons[i][1] != 0 && model != -1)
        {
            if(times > DropLimit) times = DropLimit;
            for(new a=0; a<times; a++)
            {
                new pickupid = CreatePickup(model, 3, X, Y, z);//this is the place where you die, there you will drop your weapons !
                SetTimerEx("DeletePickup", DeleteTime*1000, false, "d", pickupid);//there you may change the time 1 *1000 to *19283718293712 whatever...!
            }
        }
    }
    return 1;
}

public DeletePickup(pickupid)
{
    DestroyPickup(pickupid);
    return 1;
}
//Stock Functions
stock Path(playerid) //Will create a new stock so we can easily use it later to load/save user's data in user's path
{
    new str[128],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(str,sizeof(str),UserPath,name);
    return str;
}

stock NoMinus(string[])
{
    for(new i; i < strlen(string); i++)
    {
        if(string[i] == '-')
        {
            strdel(string, i, i+1);
        }
    }
    return string;
}

stock pWeaponSave(playerid)
{
    new string[50];
    format(string, sizeof(string), PATH, GetName(playerid));
    return string;
}


stock GetName(playerid)
{
    new name[24];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}

public RandomMessage()
{
        TextDrawSetString(ShadowsRandom, RandomMessages[random(sizeof(RandomMessages))]);
        return 1;
}

GetWeaponType(weaponid) //explainin'
{
    switch(weaponid)
    {
        case 1: return 331; case 2: return 333; case 3: return 334; // this is to define the weapons
        case 4: return 335; case 5: return 336; case 6: return 337;
        case 7: return 338; case 8: return 339; case 9: return 341;
        case 10: return 321; case 11: return 322; case 12: return 323;
        case 13: return 324; case 14: return 325; case 15: return 326;
        case 16: return 342; case 17: return 343; case 18: return 344;
        case 22: return 346; case 23: return 347; case 24: return 348;
        case 25: return 349; case 26: return 350; case 27: return 351;
        case 28: return 352; case 29: return 353; case 30: return 355;
        case 31: return 356; case 32: return 372; case 33: return 357;
        case 34: return 358; case 35: return 359; case 36: return 360;
        case 37: return 361; case 38: return 362; case 39: return 363;
        case 41: return 365; case 42: return 366; case 46: return 371; //example, this case is the id 46 is the parachute, we will drop the parachute, that's if  you got one
    }
    return -1;
}

//Commands
CMD:weapon(playerid, params[])
{
    ShowModelSelectionMenu(playerid, weaponlist, "Weapon:");
    return 1;
}

CMD:vehicle(playerid, params[])
{
    ShowModelSelectionMenu(playerid, vehiclelist, "Vehicle:");
    return 1;
}

CMD:skin(playerid, params[])
{
    ShowModelSelectionMenu(playerid, skinlist, "Select Skin:");
    return 1;
}

CMD:kill(playerid, params[])
{
    SetPlayerHealth(playerid, 0);
    return 1;
}

CMD:s(playerid, params[])
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        GetVehiclePos(vehicleid, posX[playerid], posY[playerid], posZ[playerid]);
        GetVehicleZAngle(vehicleid, posA[playerid]);
    }
    else
    {
        GetPlayerPos(playerid, posX[playerid], posY[playerid], posZ[playerid]);
        GetPlayerFacingAngle(playerid, posA[playerid]);
    }
    Interior[playerid] = GetPlayerInterior(playerid);
    VirtualWorld[playerid] = GetPlayerVirtualWorld(playerid);
    SendClientMessage(playerid, -1, "Kamu telah menyimpan posisimu");
    SendClientMessage(playerid, -1, "Gunakan /r, /loadpos Untuk memuat posisi yang disimpan!");
    Saved[playerid] = 1;
    return 1;
}

CMD:savepos(playerid, params[])
{
    return cmd_s(playerid, params);
}


CMD:r(playerid, params[])
{
    if(Saved[playerid] == 1)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            new vehicleid = GetPlayerVehicleID(playerid);
            SetVehiclePos(vehicleid, posX[playerid], posY[playerid], posZ[playerid]);
            SetVehicleZAngle(vehicleid, posA[playerid]);
            LinkVehicleToInterior(vehicleid, Interior[playerid]);
            SetVehicleVirtualWorld(vehicleid, VirtualWorld[playerid]);
        }
        else
        {
            SetPlayerPos(playerid, posX[playerid], posY[playerid], posZ[playerid]);
            SetPlayerFacingAngle(playerid, posA[playerid]);
            SetPlayerInterior(playerid, Interior[playerid]);
            SetPlayerVirtualWorld(playerid, VirtualWorld[playerid]);
        }
        SendClientMessage(playerid, -1, "Kamu telah memuat posisimu");
        SendClientMessage(playerid, -1, "Gunakan /s, /savepos Untuk menyimpan posisi yang disimpan!");
    }
    else
    {
        SendClientMessage(playerid, -1, "ERROR: Kamu belum pernah menyimpan posisi sebelumnya!");
        SendClientMessage(playerid, -1, "Gunakan /s, /savepos Untuk menyimpan posisi yang disimpan");
    }
    return 1;
}

CMD:loadpos(playerid, params[])
{
    return cmd_r(playerid, params);
}

CMD:v(playerid, params[])
{
    return cmd_vehicle(playerid, params);
}

CMD:w(playerid, params[])
{
    return cmd_weapon(playerid, params);
}

CMD:goto(playerid, params[])
{
    new targetid, string[128];
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "/goto [PlayerID/Nama]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "Pemain tidak Online");
    else
    {
        new pName[24];
        GetPlayerName(targetid,pName,128);
        format(string, sizeof(string), "Anda Telah di Teleportasi ke [%d], %s Sudah Sampai.",targetid, pName);
        SendClientMessage(playerid,-1,string);
        SetPlayerInterior(playerid,GetPlayerInterior(targetid));
        new Float:TeleX, Float:TeleY, Float:TeleZ;
        GetPlayerPos(targetid, TeleX, TeleY, TeleZ);
        SetPlayerPos(playerid, TeleX, TeleY, TeleZ+1);
    }
    return 1;
}
Reply
#2

Quote:
Originally Posted by DheWardhana
Посмотреть сообщение
in the script i dont give any GivePlayerWeapon.
sure you do. check OnPlayerSpawn.
Reply
#3

but thats it for load weapon from users.ini? i loggin with different id they still get weapon.
Reply
#4

Quote:
Originally Posted by Ada32
Посмотреть сообщение
sure you do. check OnPlayerSpawn.
Yea Right, @DheWardhana; This is your Problem Dude :-
pawn Код:
public OnPlayerSpawn(playerid)
{
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon1], WeaponInfo[playerid][Ammo1]);
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon2], WeaponInfo[playerid][Ammo2]);
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon3], WeaponInfo[playerid][Ammo3]);
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon4], WeaponInfo[playerid][Ammo4]);
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon5], WeaponInfo[playerid][Ammo5]);
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon6], WeaponInfo[playerid][Ammo6]);
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon7], WeaponInfo[playerid][Ammo7]);
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon8], WeaponInfo[playerid][Ammo8]);
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon9], WeaponInfo[playerid][Ammo9]);
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon10], WeaponInfo[playerid][Ammo10]);
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon11], WeaponInfo[playerid][Ammo11]);
    GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon12], WeaponInfo[playerid][Ammo12]);
    new PlayerName[MAX_PLAYER_NAME],
    string[128];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    format(string, sizeof(string), "%s Telah Respawn.", PlayerName);
    SendClientMessageToAll(COLOR_RED, string);
    TextDrawShowForPlayer(playerid, ShadowsRandom);
    return 1;
}
EDIT :-
Quote:
Originally Posted by DheWardhana
Посмотреть сообщение
but thats it for load weapon from users.ini? i loggin with different id they still get weapon.
That's the only GivePlayerWeapon we've seen and there is nothing more than this.
Reply
#5

How to fix it? please.. from yesterday i tired to fix this @SAMProductions
Quote:

Yea Right, @DheWardhana; This is your Problem Dude :-
pawn Code:
public OnPlayerSpawn(playerid)
{
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon1], WeaponInfo[playerid][Ammo1]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon2], WeaponInfo[playerid][Ammo2]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon3], WeaponInfo[playerid][Ammo3]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon4], WeaponInfo[playerid][Ammo4]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon5], WeaponInfo[playerid][Ammo5]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon6], WeaponInfo[playerid][Ammo6]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon7], WeaponInfo[playerid][Ammo7]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon8], WeaponInfo[playerid][Ammo8]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon9], WeaponInfo[playerid][Ammo9]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon10], WeaponInfo[playerid][Ammo10]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon11], WeaponInfo[playerid][Ammo11]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon12], WeaponInfo[playerid][Ammo12]);
new PlayerName[MAX_PLAYER_NAME],
string[128];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "%s Telah Respawn.", PlayerName);
SendClientMessageToAll(COLOR_RED, string);
TextDrawShowForPlayer(playerid, ShadowsRandom);
return 1;
}

Reply
#6

Try This :-
pawn Код:
public OnPlayerSpawn(playerid)
{
    new PlayerName[MAX_PLAYER_NAME],
    string[128];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    format(string, sizeof(string), "%s Telah Respawn.", PlayerName);
    SendClientMessageToAll(COLOR_RED, string);
    TextDrawShowForPlayer(playerid, ShadowsRandom);
    return 1;
}
I just remove your "GivePlayerWeapon" Code

EDIT :-

If it is not working then Reply here again
Reply
#7

Reset them on connect.

Set WeaponInfo[playerid][Weapon1] - WeaponInfo[playerid][Weapon12] and WeaponInfo[playerid][Ammo1] - WeaponInfo[playerid][Ammo12] to 0.

So when a player leaves (who had weapons) and a new player joins (who is not register), then he won't get the weapons of the previous player.
Reply
#8

Okay ..
Reply
#9

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Reset them on connect.

Set WeaponInfo[playerid][Weapon1] - WeaponInfo[playerid][Weapon12] and WeaponInfo[playerid][Ammo1] - WeaponInfo[playerid][Ammo12] to 0.

So when a player leaves (who had weapons) and a new player joins (who is not register), then he won't get the weapons of the previous player.
Agree with Konstantinos
Reply
#10

Can you give the full script i confused.. sorry

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Reset them on connect.

Set WeaponInfo[playerid][Weapon1] to WeaponInfo[playerid][Weapon12] and WeaponInfo[playerid][Ammo1] to WeaponInfo[playerid][Ammo12] to 0.

So when a player leaves (who had weapons) and a new player joins (who is not register), then he won't get the weapons of the previous player.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)