Help with the Returns
#1

Hi , the problem is simple : whene i go In Game i don't have Vip Privilages (i maked mu VipLevel=3 )
this is the Public onplayerspawn :
pawn Код:
public OnPlayerSpawn(playerid)
{
SetTimerEx("CheckThings",5000,1,"i",playerid);
    new cfile[100]; format(cfile,100,"ERegLog/Config/Config.ini");
    new file[100],Name[MAX_PLAYER_NAME]; GetPlayerName(playerid,Name,MAX_PLAYER_NAME); format(file,sizeof(file),PlayerFile,Name);
    if(cInfo[SkinLoad] == 1)
    {
    SetPlayerSkin(playerid,dini_Int(file,"Skin"));
    }
    else
    {
    return 1;
    }
    if(cInfo[WantedLevelLoad] == 1)
    {
    SetPlayerWantedLevel(playerid,dini_Int(file,"Wanted Level"));
    }
    else
    {
    return 1;
    }
    if(cInfo[WeaponsLoad] == 1)
    {
    GivePlayerWeapon(playerid,dini_Int(file,"Weapon 1"),dini_Int(file,"Ammo 1"));
    GivePlayerWeapon(playerid,dini_Int(file,"Weapon 2"),dini_Int(file,"Ammo 2"));
    GivePlayerWeapon(playerid,dini_Int(file,"Weapon 3"),dini_Int(file,"Ammo 3"));
    GivePlayerWeapon(playerid,dini_Int(file,"Weapon 4"),dini_Int(file,"Ammo 4"));
    GivePlayerWeapon(playerid,dini_Int(file,"Weapon 5"),dini_Int(file,"Ammo 5"));
    GivePlayerWeapon(playerid,dini_Int(file,"Weapon 6"),dini_Int(file,"Ammo 6"));
    GivePlayerWeapon(playerid,dini_Int(file,"Weapon 7"),dini_Int(file,"Ammo 7"));
    GivePlayerWeapon(playerid,dini_Int(file,"Weapon 8"),dini_Int(file,"Ammo 8"));
    }
    else
    {
    return 0;
    }
    SetPlayerToTeamColor(playerid);
   
    if(gTeam[playerid] == TEAM_ZOMBIE)
    {
        gTeam[playerid] = TEAM_ZOMBIE;
        ResetPlayerWeapons(playerid);
        GameTextForPlayer(playerid,"you are a Zombie",1,1);
    }
    if (pInfo[playerid][VipLevel] == 0)
    {
        SendClientMessage(playerid, COLOR_LIGHTGREEN, " You are a Normal player , you don't have any privilages.");
    }
    else if (pInfo[playerid][VipLevel] == 1)
    {
        GivePlayerWeapon(playerid , 22, 20);
        GivePlayerMoney(playerid, 30);
        SendClientMessage(playerid, COLOR_GREY, "You are (VIP:Silver) you earn $30 and a colt45 with 20 ammo.");
    }
    else if (pInfo[playerid][VipLevel] == 2)
    {
        GivePlayerWeapon(playerid , 22, 50);
        GivePlayerMoney(playerid, 100);
        SendClientMessage(playerid, COLOR_YELLOW3, "You are (VIP:Gold) you earn $100 and a colt45 with 50 ammo.");
    }
    else if (pInfo[playerid][VipLevel] == 3)
    {
        GivePlayerWeapon(playerid , 25, 50);
        GivePlayerWeapon(playerid , 22, 50);
        GivePlayerMoney(playerid,GetPlayerMoney(playerid)+250);
        SendClientMessage(playerid, COLOR_GREY, "You are (VIP:Premium) you earn $250 and a colt45+shotgun with 50 ammo.");
    }
    return 1;
}
i said maybe because there are a lot of returns , or i shall add the Vip system before the weapons...
Reply
#2

yep, the returns triggered as soon one condition wasnt met, heres the fixed code:
pawn Код:
public OnPlayerSpawn(playerid)
{
    SetTimerEx("CheckThings",5000,1,"i",playerid);
    new cfile[100]; format(cfile,100,"ERegLog/Config/Config.ini");
    new file[100],Name[MAX_PLAYER_NAME]; GetPlayerName(playerid,Name,MAX_PLAYER_NAME); format(file,sizeof(file),PlayerFile,Name);
    if(cInfo[SkinLoad] == 1)
    {
        SetPlayerSkin(playerid,dini_Int(file,"Skin"));
    }
    if(cInfo[WantedLevelLoad] == 1)
    {
        SetPlayerWantedLevel(playerid,dini_Int(file,"Wanted Level"));
    }
    if(cInfo[WeaponsLoad] == 1)
    {
        GivePlayerWeapon(playerid,dini_Int(file,"Weapon 1"),dini_Int(file,"Ammo 1"));
        GivePlayerWeapon(playerid,dini_Int(file,"Weapon 2"),dini_Int(file,"Ammo 2"));
        GivePlayerWeapon(playerid,dini_Int(file,"Weapon 3"),dini_Int(file,"Ammo 3"));
        GivePlayerWeapon(playerid,dini_Int(file,"Weapon 4"),dini_Int(file,"Ammo 4"));
        GivePlayerWeapon(playerid,dini_Int(file,"Weapon 5"),dini_Int(file,"Ammo 5"));
        GivePlayerWeapon(playerid,dini_Int(file,"Weapon 6"),dini_Int(file,"Ammo 6"));
        GivePlayerWeapon(playerid,dini_Int(file,"Weapon 7"),dini_Int(file,"Ammo 7"));
        GivePlayerWeapon(playerid,dini_Int(file,"Weapon 8"),dini_Int(file,"Ammo 8"));
    }
    SetPlayerToTeamColor(playerid);
    if(gTeam[playerid] == TEAM_ZOMBIE)
    {
        gTeam[playerid] = TEAM_ZOMBIE;
        ResetPlayerWeapons(playerid);
        GameTextForPlayer(playerid,"you are a Zombie",1,1);
    }
    switch(pInfo[playerid][VipLevel])
    {
        case 0:
        {
            SendClientMessage(playerid, COLOR_LIGHTGREEN, " You are a Normal player , you don't have any privilages.");
        }
        case 1:
        {
            GivePlayerWeapon(playerid , 22, 20);
            GivePlayerMoney(playerid, 30);
            SendClientMessage(playerid, COLOR_GREY, "You are (VIP:Silver) you earn $30 and a colt45 with 20 ammo.");
        }
        case 2:
        {
            GivePlayerWeapon(playerid , 22, 50);
            GivePlayerMoney(playerid, 100);
            SendClientMessage(playerid, COLOR_YELLOW3, "You are (VIP:Gold) you earn $100 and a colt45 with 50 ammo.");
        }
        case 3:
        {
            GivePlayerWeapon(playerid , 25, 50);
            GivePlayerWeapon(playerid , 22, 50);
            GivePlayerMoney(playerid,GetPlayerMoney(playerid)+250);
            SendClientMessage(playerid, COLOR_GREY, "You are (VIP:Premium) you earn $250 and a colt45+shotgun with 50 ammo.");
        }
    }
    return 1;
}
Reply
#3

Thanks ! it is working
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)