Script issues on a gamemode made from scratch.
#1

Ok so recently i hit the "new" button on pawn and got tired of editing other scripts, and wanted to make my own RP gamemode, not really to start my own server, just for the heck of it and to learn more about scripting and to release it later. Using samp tutorials ect i manged to get pretty decently far in the gamemode. Login and register thanks to kush tutorial, and a few others who helped me with ideas or bug fixing on the forum. But now i have ran into another problem.

I have a basic admin system. when i /sethp [id] [0] the player dies, but their deaths dont go up. if they die, their deaths wont increase, nor will their kills, the cash isnt saving, and the amount of cash i want each player to start with wont save. As well as if my server restarts or crashes the players skin or stats wont be saved. and YES i have been searching the forums for answers but no helpful ones have been found.

pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    PlayerInfo[killerid][pKills]++;
    PlayerInfo[playerid][pDeaths]++;
    SetPlayerPos(playerid, 2033.8181, -1403.8074, 17.2754);
    GivePlayerMoney(playerid, -2000);
    SpawnPlayer(playerid);
    return 1;
}
Reply
#2

Well you should do a check to make sure the killerid is valid before adding a kill to his stats. Also, why are you setting the player's position and calling SpawnPlayer under OnPlayerDeath?

pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID)
        PlayerInfo[killerid][pKills]++;
       
    PlayerInfo[playerid][pDeaths]++;
    GivePlayerMoney(playerid, -2000);
    return 1;
}
Try that out. As for your other problems, you need to show more code specific to those areas. Hope that helps.
Reply
#3

For the 'not saving' part you need to drop your OnPlayerDisconnect.
Reply
#4

You need to check if killerid != INVALID_PLAYER_ID otherwise the script won't execute the code under that line.
Reply
#5

Quote:
Originally Posted by Backwardsman97
View Post
Well you should do a check to make sure the killerid is valid before adding a kill to his stats. Also, why are you setting the player's position and calling SpawnPlayer under OnPlayerDeath?

pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID)
        PlayerInfo[killerid][pKills]++;
       
    PlayerInfo[playerid][pDeaths]++;
    GivePlayerMoney(playerid, -2000);
    return 1;
}
Try that out. As for your other problems, you need to show more code specific to those areas. Hope that helps.
That worked perfectly Thanks.

Heres my:OnPlayerDisconnect
pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
    GetPlayerMoney(playerid);
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Level",PlayerInfo[playerid][pLevel]);
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Sex",PlayerInfo[playerid][pSex]);
    INI_WriteInt(File,"Age",PlayerInfo[playerid][pAge]);
    INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
    INI_WriteInt(File,"Leader",PlayerInfo[playerid][pLeader]);
    INI_WriteInt(File,"Rank",PlayerInfo[playerid][pRank]);
    INI_WriteInt(File,"Team",PlayerInfo[playerid][pTeam]);
    INI_WriteInt(File,"Member",PlayerInfo[playerid][pMember]);
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Vip",PlayerInfo[playerid][pVip]);
    INI_WriteInt(File,"Muted",PlayerInfo[playerid][pMuted]);
    INI_WriteInt(File,"Tutorial",PlayerInfo[playerid][pTut]);
    INI_WriteInt(File,"Mute Time",PlayerInfo[playerid][pMuteTime]);
    INI_WriteInt(File,"Banned",PlayerInfo[playerid][pLocked]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Close(File);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)