SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 17/11/2013, 02:37 PM   #1
Mey6155
Big Clucker
 
Join Date: Nov 2013
Posts: 131
Reputation: 3
Default Saving PlayerHealth and Armour will kill them.

pawn Code:
enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths,
    pJob,
    pJobRank,
    pBanned,
    pWarn,
    pBankmoney,
    pSkin,
    pMuted,
    pNewb,
    Float:Health,
    Float:Armour,
    pGun1,
    pGun2,
    pGun3,
    pAmmo1,
    pAmmo2,
    pAmmo3
}
new PlayerInfo[MAX_PLAYERS][pInfo];

pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
    new Float:hp, Float:armour;
    new INI:File = INI_Open(UserPath(playerid));
    PlayerInfo[playerid][Health] = GetPlayerHealth(playerid, hp);
    PlayerInfo[playerid][Armour] = GetPlayerArmour(playerid, armour);
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"Job",PlayerInfo[playerid][pJob]);
    INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]);
    INI_WriteInt(File,"Warn",PlayerInfo[playerid][pWarn]);
    INI_WriteInt(File,"BankMoney",PlayerInfo[playerid][pBankmoney]);
    INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
    INI_WriteInt(File,"Muted",PlayerInfo[playerid][pMuted]);
    INI_WriteInt(File,"Newb",PlayerInfo[playerid][pNewb]);
    INI_WriteFloat(File, "Health", PlayerInfo[playerid][Health]);
    INI_WriteFloat(File, "Armour", PlayerInfo[playerid][Armour]);
    INI_WriteInt(File,"Gun1",PlayerInfo[playerid][pGun1]);
    INI_WriteInt(File,"Gun2",PlayerInfo[playerid][pGun2]);
    INI_WriteInt(File,"Gun3",PlayerInfo[playerid][pGun3]);
    INI_WriteInt(File,"Ammo1",PlayerInfo[playerid][pAmmo1]);
    INI_WriteInt(File,"Ammo2",PlayerInfo[playerid][pAmmo2]);
    INI_WriteInt(File,"Ammo3",PlayerInfo[playerid][pAmmo3]);
    INI_Close(File);
    GetPlayerWeaponData(playerid, 1, PlayerInfo[playerid][pGun1], PlayerInfo[playerid][pAmmo1]);
    GetPlayerWeaponData(playerid, 2, PlayerInfo[playerid][pGun2], PlayerInfo[playerid][pAmmo2]);
    GetPlayerWeaponData(playerid, 3, PlayerInfo[playerid][pGun3], PlayerInfo[playerid][pAmmo3]);
    return 1;
}
pawn Code:
public OnPlayerSpawn(playerid)
{
    //new mess[256],IP[256];
    //GetPlayerIp(playerid,IP,sizeof(IP));
    SetPlayerSkin(playerid, skins[random(13)]);
    SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
    //format(mess,sizeof(mess),"%s has joined the server. [IP Address: %s ]",GetName(playerid),IP);
    //printf(mess);
    //SendClientMessageToAll(-1,mess);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        SetPlayerMarkerForPlayer(i,playerid,00);
    }
    SetPlayerHealth(playerid, PlayerInfo[playerid][Health]);
    SetPlayerArmour(playerid, PlayerInfo[playerid][Armour]);
    GivePlayerWeapon(playerid, PlayerInfo[playerid][pGun1], PlayerInfo[playerid][pAmmo1]);
    GivePlayerWeapon(playerid, PlayerInfo[playerid][pGun2], PlayerInfo[playerid][pAmmo2]);
    GivePlayerWeapon(playerid, PlayerInfo[playerid][pGun3], PlayerInfo[playerid][pAmmo3]);
    return 1;
}
pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registering...","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",25000);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"Job",0);
                INI_WriteInt(File,"Banned",0);
                INI_WriteInt(File,"Warn",0);
                INI_WriteInt(File,"BankMoney",0);
                INI_WriteInt(File,"Skin",0);
                INI_WriteInt(File,"Muted",0);
                INI_WriteInt(File,"Newb",0);
                INI_WriteFloat(File,"Health",100);
                INI_WriteFloat(File,"Armour",15);
                INI_WriteInt(File,"Gun1",0);
                INI_WriteInt(File,"Gun2",0);
                INI_WriteInt(File,"Gun3",0);
                INI_WriteInt(File,"Ammo1",0);
                INI_WriteInt(File,"Ammo2",0);
                INI_WriteInt(File,"Ammo3",0);
                INI_Close(File);

                SetSpawnInfo(playerid, 0, skins[random(13)], 2127.5403, 2369.9082, 10.8203, 269.15, 0, 0, 0, 0, 0, 0);
                SetPlayerSkin(playerid, skins[random(13)]);
                SpawnPlayer(playerid);
                SetPlayerHealth(playerid, 100);
                SetPlayerArmour(playerid, 15);
                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,"Success!","Great! Your Y_INI system works perfectly. Relog to save your stats!","Ok","");
            }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,"Success!","","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","You have entered an incorrect password.\nType your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}
pawn Code:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("Job",PlayerInfo[playerid][pJob]);
    INI_Int("JobRank",PlayerInfo[playerid][pJobRank]);
    INI_Int("Banned",PlayerInfo[playerid][pBanned]);
    INI_Int("Warn",PlayerInfo[playerid][pWarn]);
    INI_Int("BankMoney",PlayerInfo[playerid][pBankmoney]);
    INI_Int("Skin",PlayerInfo[playerid][pSkin]);
    INI_Int("Muted",PlayerInfo[playerid][pMuted]);
    INI_Int("Newb",PlayerInfo[playerid][pNewb]);
    INI_Float("Health", PlayerInfo[playerid][Health]);
    INI_Float("Armour", PlayerInfo[playerid][Armour]);
    INI_Int("Gun1",PlayerInfo[playerid][pGun1]);
    INI_Int("Gun2",PlayerInfo[playerid][pGun2]);
    INI_Int("Gun3",PlayerInfo[playerid][pGun3]);
    INI_Int("Ammo1",PlayerInfo[playerid][pAmmo1]);
    INI_Int("Ammo2",PlayerInfo[playerid][pAmmo2]);
    INI_Int("Ammo3",PlayerInfo[playerid][pAmmo3]);
    return 1;

}

If a new player joins the server and register and spawns he got killd but i have when he register health = 100 armour = 15 but it just kill him ;(

And if you change it at scriptfiles to 100 and play it works when you logout its 1.0000 again
Please help me
Mey6155 is offline   Reply With Quote
Old 17/11/2013, 02:41 PM   #2
Voxel
Gangsta
 
Voxel's Avatar
 
Join Date: Sep 2013
Location: The Netherlands
Posts: 578
Reputation: 70
Default Re: Saving PlayerHealth and Armour will kill them.

Under OnPlayerConnect, set his hp to 100, and also under OnPlayerSpawn to be sure that his HP value is set properly.
__________________
My Work:
[GameMode]The Nether Survival
[Filterscript]SQLite Database Start
[Tutorial]SQLite Commands
[Tutorial]Loot/ Inventory System
[Tutorial]Simple Hunger/Thirst System
[Tutorial]Converting Binary
[Map]Tropical Island + Pier
[Map]San Fierro Apocalypse
Voxel is offline   Reply With Quote
Old 17/11/2013, 02:50 PM   #3
Mey6155
Big Clucker
 
Join Date: Nov 2013
Posts: 131
Reputation: 3
Default Re: Saving PlayerHealth and Armour will kill them.

No, not that it is'ny logic in a Roleplay server to start always with 100hp another way?
Mey6155 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Armour Saving. - Not working. Dokins Scripting Help 1 25/02/2013 09:20 PM
What am I doing wrong here, Armour Saving. Dokins Scripting Help 5 25/11/2012 09:08 PM
Get score, armour and health after kill. Subwoofer Scripting Help 7 03/06/2012 01:32 PM
Saving health and armour Osviux Help Archive 17 21/06/2011 02:44 PM


All times are GMT. The time now is 04:45 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.