Jump to content
  • 0

Problema spawn


H3ater.SG

Question

3 answers to this question

Recommended Posts

  • 0
public OnPlayerSpawn(playerid) {
    #if defined DEBUG
        printf("[debug] OnPlayerSpawn(%d)", playerid);
    #endif

    Alive[playerid] = 1;
    CheckDelay[playerid] = 2;
    SpawnTimes[playerid]++;
    if(SpawnTimes[playerid]==1) Distance[playerid] = 0;

    StopAudioStreamForPlayer(playerid);

    SetPlayerSkin(playerid, playerVariables[playerid][pSkin]);
    SetPlayerHealth(playerid, 99);

    for(new i=0; i<10; i++)
     {
        SendDeathMessageToPlayer(playerid,202, 202, 202);
    }

    TextDrawHideForPlayer(playerid, DMV2[playerid]);
    TextDrawHideForPlayer(playerid, DMV1[playerid]);
    
    PreloadAnimLib(playerid,"BOMBER");
    PreloadAnimLib(playerid,"RAPPING");
    PreloadAnimLib(playerid,"SHOP");
    PreloadAnimLib(playerid,"BEACH");
    PreloadAnimLib(playerid,"SMOKING");
    PreloadAnimLib(playerid,"ON_LOOKERS");
    PreloadAnimLib(playerid,"DEALER");
    PreloadAnimLib(playerid,"CRACK");
    PreloadAnimLib(playerid,"CARRY");
    PreloadAnimLib(playerid,"COP_AMBIENT");
    PreloadAnimLib(playerid,"PARK");
    PreloadAnimLib(playerid,"INT_HOUSE");
    PreloadAnimLib(playerid,"FOOD");
    PreloadAnimLib(playerid,"GANGS");
    PreloadAnimLib(playerid,"PED");
    PreloadAnimLib(playerid,"FAT");
    
    TogglePlayerSpectating(playerid, 0);
    
    playerVariables[playerid][pWeapons][0] = 0;
    playerVariables[playerid][pWeapons][1] = 0;
    playerVariables[playerid][pWeapons][2] = 0;
    playerVariables[playerid][pWeapons][3] = 0;
    playerVariables[playerid][pWeapons][4] = 0;
    playerVariables[playerid][pWeapons][5] = 0;
    playerVariables[playerid][pWeapons][6] = 0;
    playerVariables[playerid][pWeapons][7] = 0;
    playerVariables[playerid][pWeapons][8] = 0;
    playerVariables[playerid][pWeapons][9] = 0;
    playerVariables[playerid][pWeapons][10] = 0;
    playerVariables[playerid][pWeapons][11] = 0;
    playerVariables[playerid][pWeapons][12] = 0;

     SetPlayerToTeamColor(playerid);
    
    SetPlayerFightingStyle(playerid, playerVariables[playerid][pFightStyle]);
    
    HUndercover[playerid] = 0;
    if(playerVariables[playerid][pPrisonTime] >= 1)
    {
        switch(playerVariables[playerid][pPrisonID])
        {
            case 2:
            {
                ResetPlayerWeapons(playerid);
                SetPlayerInterior(playerid, 10);
                SetPlayerVirtualWorld(playerid, 0);
                SetPlayerPos(playerid, 223.15, 110.0, 999.02);
            }
            case 3:
            {
                ResetPlayerWeapons(playerid);
                SetPlayerInterior(playerid, 6);
                new spawn = random(sizeof(JailSpawns));
                SetPlayerPos(playerid, JailSpawns[spawn][0], JailSpawns[spawn][1], JailSpawns[spawn][2]);
                SetPlayerFacingAngle(playerid, 0);
            }
        }
        return 1;
    }
    new rand;
    if(PlayerPaintballing[playerid] != 0)
    {
        GivePlayerWeaponEx(playerid, pgunp, 9999);
        curatj[playerid] = 1;
        rand = random(sizeof(PaintballSpawns));
        SetPlayerPos(playerid, PaintballSpawns[rand][0], PaintballSpawns[rand][1], PaintballSpawns[rand][2]);
           SetPlayerInterior(playerid, 10);
           SetPlayerSkin(playerid, 250);
        return 1;
    }
    if((playerVariables[playerid][pPDuty] == 1) && (playerVariables[playerid][pGroup] == 1|| playerVariables[playerid][pGroup] == 2 || playerVariables[playerid][pGroup] == 3 || playerVariables[playerid][pGroup] == 5))
    {
        GivePlayerWeapon(playerid, 24, 9999);
        GivePlayerWeapon(playerid, 31, 9999);
        GivePlayerWeapon(playerid, 29, 9999);
        GivePlayerWeapon(playerid, 41, 9999);
        playerVariables[playerid][pWeapons][0] = 24;
        playerVariables[playerid][pWeapons][1] = 31;
        playerVariables[playerid][pWeapons][2] = 29;
        playerVariables[playerid][pWeapons][3] = 41;
        SetPlayerHealth(playerid, 99);
        SetPlayerArmour(playerid, 99);
    }    
    if(playerVariables[playerid][pSpawnChange] == 1)
    {
        new houseID = getPlayerHouseID(playerid);
        new houserented = playerVariables[playerid][pHouseRented];
        if(houseID >= 1)
        {
            SetPlayerInterior(playerid, houseVariables[houseID][hHouseInteriorID]);
            SetPlayerVirtualWorld(playerid, HOUSE_VIRTUAL_WORLD+houseID);
            SetPlayerPos(playerid, houseVariables[houseID][hHouseInteriorPos][0], houseVariables[houseID][hHouseInteriorPos][1], houseVariables[houseID][hHouseInteriorPos][2]);
            InHouse[playerid] = houseID;
            if(houseVariables[houseID][hStreamType] == 2)
            {
                YoutubeStreamForPlayer(playerid, houseVariables[houseID][hStream]);
            }
            else if(houseVariables[houseID][hStreamType] == 1)
            {
                PlayAudioStreamForPlayer(playerid, houseVariables[houseID][hStream]);
            }
        }
        else
        {
            if(houserented >= 1)
            {
                SetPlayerInterior(playerid, houseVariables[houserented][hHouseInteriorID]);
                SetPlayerVirtualWorld(playerid, HOUSE_VIRTUAL_WORLD+houserented);
                SetPlayerPos(playerid, houseVariables[houserented][hHouseInteriorPos][0], houseVariables[houserented][hHouseInteriorPos][1], houseVariables[houserented][hHouseInteriorPos][2]);
                InHouse[playerid] = houserented;
            }
            else
            {
                playerVariables[playerid][pSpawnChange] = 0;
            }
        }
    }
    if(playerVariables[playerid][pSpawnChange] == 0)
    {
        if(playerVariables[playerid][pGroup] == 0)
        {
            SetPlayerPos(playerid, 1800.1593,-1863.6956,13.5748);
            
            SetPlayerInterior(playerid, 0);
            SetPlayerVirtualWorld(playerid, 0);
        }
        else
        {
            new group;
            group = playerVariables[playerid][pGroup];
            SetPlayerPos(playerid, groupVariables[group][gGroupInteriorPos][0], groupVariables[group][gGroupInteriorPos][1], groupVariables[group][gGroupInteriorPos][2]);
            SetPlayerInterior(playerid, groupVariables[group][gGroupHQInteriorID]);
            SetPlayerVirtualWorld(playerid, GROUP_VIRTUAL_WORLD+group);
        }
    }
    


    SetCameraBehindPlayer(playerid);
    
    ResetPlayerWeapons(playerid);
    
    givePlayerWeapons(playerid);
    
    SetPlayerWeather(playerid, 1);

    syncPlayerTime(playerid);
    SetPlayerSpawn(playerid);
    TogglePlayerControllable(playerid, true);

    return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{  
    Alive[playerid] = 0;
    CheckDelay[playerid] = 10;
    TextDrawHideForPlayer(playerid, Status[playerid]);
    new vehicleid = GetPlayerVehicleID(playerid);
    if(vehicleVariables[vehicleid][vVehicleJob] == 7)
    {
        format(szMessage, sizeof(szMessage), "Job failed.");
        SCM(playerid, COLOR_NOB, szMessage);
        SetVehicleToRespawnEx(vehicleid);
        KillTimer(mowertimer[playerid]);
        MowerMoney[playerid] = 0;
        TextDrawHideForPlayer(playerid,Mower[playerid]);
        playerVariables[playerid][pFarmerMoney] = 0;

    }
    if(PlayerPaintballing[playerid] != 0)
    {
            foreach(Player, x)
            {
                if((PlayerPaintballing[playerid] != 0 && PlayerPaintballing[killerid] != 0) && PlayerPaintballing[x])
                {
                    SendDeathMessageToPlayer(x, killerid, playerid, reason);
                }
            }
            new string[500];

            
            new pinfo[128];
            KillP[killerid]++;
            DeathP[playerid]++;

            format(string, sizeof(string), "You have killed %s. You now have %d kills.",GetName(playerid), KillP[killerid]);
            SendClientMessage(killerid, COLOR_GENANNOUNCE, string);
            
            format(string, sizeof(string), "You have been killed by %s.",GetName(killerid));
            SendClientMessage(playerid, COLOR_GENANNOUNCE, string);

            PlayerPaintballScore[killerid] = KillP[killerid];
            if(PlayerPaintballScore[killerid] > PaintballWinnerScore)
            {
                PaintballWinner = killerid;
                PaintballWinnerScore = PlayerPaintballScore[killerid];
                foreach(Player,i)
                {
                    if(IsPlayerConnected(i))
                    {
                        if(PlayerPaintballing != 0)
                        {
                            format(pinfo,sizeof(pinfo),"%s is now in lead with %d kills.",GetName(PaintballWinner),PaintballWinnerScore);
                            SCM(i, COLOR_YELLOW, pinfo);
                           }
                    }
                   }
            }
            return 1;
    }
    KillTimer(mowertimer[playerid]);
    if(playerVariables[playerid][pHeadValue] > 0)
    {
        if(IsPlayerConnected(killerid))
        {
            if(playerVariables[killerid][pGroup] == 12)
            {
                if(GoChase[killerid] == playerid)
                {
                    new string[256];
                    new killer[MAX_PLAYER_NAME];
                    new name[MAX_PLAYER_NAME];
                    GetPlayerName(killerid, killer, sizeof(killer));
                    GetPlayerName(playerid, name, sizeof(name));
                    playerVariables[killerid][pMoney] += playerVariables[playerid][pHeadValue];
                    format(string,128,"%s has succesfully completed the contract on %s for $%d, distance: %.0fm.",killer,name,playerVariables[playerid][pHeadValue], GetDistanceBetweenPlayers(killerid, playerid));
                    SendToGroup(12, COLOR_HIT, string);
                    playerVariables[playerid][pHeadValue] = -1;
                    GotHit[playerid] = 0;
                    GetChased[playerid] = 999;
                    GoChase[killerid] = 999;
                }
            }
        }
     }
    new turfkiller, turfplayerid;
    for(new i = 0; i <= sizeof(TurfInfo); i++)
    {
        if(IsPlayerInTurf(playerid, i) == 1)
        {
            turfplayerid = i;
            break;
        }
    }
    for(new i = 0; i <= sizeof(TurfInfo); i++)
    {
        if(IsPlayerInTurf(killerid, i) == 1)
        {
            turfkiller = i;
            break;
        }
    }
    new string[256];
    if(WarInfo[turfplayerid][wTime] > 0 && WarInfo[turfkiller][wTime] > 0)
        {
            if(turfplayerid == turfkiller)
            {
                if(playerVariables[playerid][pGroup] == WarInfo[turfplayerid][wAttacker] && playerVariables[killerid][pGroup] == WarInfo[turfplayerid][wFaction])
                {
                    playerVariables[playerid][pWarDeaths] += 1;
                    format(string, sizeof(string), "You have been killed by %s (%i)", playerVariables[killerid][pNormalName], killerid);
                    SCM(playerid, COLOR_GENANNOUNCE, string);

                    groupVariables[WarInfo[turfkiller][wFaction]][gScore] += 1;
                    playerVariables[killerid][pWarScore] += 1;
                    format(string, sizeof(string), "You have killed %s (%i).", playerVariables[playerid][pNormalName], playerid);
                    SCM(killerid, COLOR_GENANNOUNCE, string);

                    foreach(Player, x)
                    {
                        if(playerVariables[x][pGroup] == WarInfo[turfplayerid][wAttacker] || playerVariables[x][pGroup] == WarInfo[turfplayerid][wFaction])
                        {
                            SendDeathMessageToPlayer(x, killerid, playerid, reason);
                        }
                    }
                    SCM(playerid, COLOR_LIGHTBLUE, "You will be spawned in the HQ.");
                }
                else if(playerVariables[killerid][pGroup] == WarInfo[turfkiller][wAttacker] && playerVariables[playerid][pGroup] == WarInfo[turfkiller][wFaction])
                {
                    playerVariables[playerid][pWarDeaths] += 1;
                    format(string, sizeof(string), "You have been killed by %s (%i).", playerVariables[killerid][pNormalName], killerid);
                    SCM(playerid, COLOR_GENANNOUNCE, string);

                    groupVariables[WarInfo[turfplayerid][wAttacker]][gScore] += 1;
                    playerVariables[killerid][pWarScore] += 1;
                    format(string, sizeof(string), "You have killed %s (%i).", playerVariables[playerid][pNormalName], playerid);
                    SCM(killerid, COLOR_GENANNOUNCE, string);

                    foreach(Player, x)
                    {
                        if(playerVariables[x][pGroup] == WarInfo[turfplayerid][wAttacker] || playerVariables[x][pGroup] == WarInfo[turfplayerid][wFaction])
                        {
                            SendDeathMessageToPlayer(x, killerid, playerid, reason);
                        }
                    }
                    SCM(playerid, COLOR_LIGHTBLUE, "You will be spawned in group HQ.");
                }
            }
        }
     if((WarInfo[turfkiller][wTime] != 0 && (WarInfo[turfkiller][wAttacker] == playerVariables[playerid][pGroup] || WarInfo[turfkiller][wFaction] == playerVariables[playerid][pGroup]) && playerVariables[playerid][pGroup] != 0) || (playerVariables[killerid][pGroup] == 1
     || playerVariables[killerid][pGroup] == 2 || playerVariables[killerid][pGroup] == 3 || playerVariables[killerid][pGroup] == 5) || (playerVariables[playerid][pGroup] == 1 || playerVariables[playerid][pGroup] == 2 || playerVariables[playerid][pGroup] == 3 || playerVariables[playerid][pGroup] == 5) || (playerVariables[playerid][pGroup] == playerVariables[killerid][pGroup]) || (PlayerPaintballing[killerid] >= 1))
    {
            
    }
    else
    {
        WantedID[playerid] = killerid;
        SCM(playerid, COLOR_GENANNOUNCE, "You have been attacked by another player. You have 60 seconds to call the police to report this crime. Use /call 112.");
        WantedIDTime[playerid] = 60;
    }
    //SetTimerEx("Spawn", 3999, 0, "d", playerid);
    SetPlayerHealth(playerid, 0);
    killerid = INVALID_PLAYER_ID;
    return 1;

}

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.