Hello A LittLe Problem.
#1

PHP Code:
function StartMap()
{
    
//ClearChat();
    
foreach(Player,i)
    {
        
SetCameraBehindPlayer(i);
        
ClearAnimations(i);
        
HumanSetup(i);
        
SpawnPlayer(i);
        
CurePlayer(i);
        
SetPlayerDrunkLevel(i,0);
        
DisablePlayerCheckpoint(i);
        
pInfo[i][Boxes] = 2;
        
pInfo[i][BoxesAdvanced] = 10;
        
pInfo[i][SkinChanges] = 2;
        
pInfo[i][ArmourChanges] = 2;
        
pInfo[i][pVipBoxes] = 35;
        
pInfo[i][pLadders] = 2;
        
pInfo[i][pFakeKills] = 0;
        
pInfo[i][pAmmoBoxes] = 10;
        
pInfo[i][pKillsIn1Map] = 0;
        
pInfo[i][C4] = 4;
        
pInfo[i][pTrapMasterTrap] = 1;
        
pInfo[i][pScientistCure] = 1;
        
pInfo[i][pDoctorShield] = 1;
        
pInfo[i][pMapsPlayed]++;
        
TextDrawHideForPlayer(iServerIntroOne[i]);
        
TextDrawHideForPlayer(iServerIntroTwo[i]);
        
DestroyPickup(meatDrops[i]);
        
DestroyPickup(ammoDrops[i]);
        
DestroyObject(DocShield);
        
DestroyObject(Trap);
        
TogglePlayerControllable(i,1);
    }
    
time MAX_MAPTIME;
    
SetWeather(Map[Weather]);
    
SetWorldTime(Map[Time]);
    
UpdateMapName();
/*    SendClientMessageToAll(-1,""chat""COL_LGREEN" [Clear]"COL_WHITE" Chat Cleared "COL_YELLOW"[Reason: Next Map]");
    SendClientMessageToAll(-1,""chat""COL_RED" [Info]"COL_WHITE" These maps are created by Iffet Mappers");*/
    
SetTimer("RandomZombie",1000,false);
    
gateobj CreateObject(Map[GateID],Map[GateX],Map[GateY],Map[GateZ],Map[GaterX],Map[GaterY],Map[GaterZ],500.0);
    
mapvar SetTimer("OnMapUpdate",MAX_MAPUPDATE_TIME,true);
    
balvar SetTimer("OnMapBalance",MAX_BALANCERUPDATE_TIME,true);
    if(
randomid == INVALID_PLAYER_ID || IsPlayerConnected(randomid))
    {
    new 
onlineids[MAX_PLAYERS]; // to store all online playerids
    
new playersonline// to store the amount of current online players
    
new pname1[16]; // to store the chosen player's name
    
for(new i=0i<MAX_PLAYERSi++) // loop through max amount of players (hopefully redefined from default!)
    
{
        if(
IsPlayerConnected(i)) // check to see if current id in the loop is connected
        
{
            
onlineids[playersonline] = i// store the current id into the onlineids variable
            
playersonline++; // increase the playersonline by 1
        
}
        else
        {
        
//print("id is not connected.");
        
SetTimer("BonusPlayer"6*10000);
        }
    }
    
randmoney random(50000 1000) + 1000;
    
//GivePlayerMoney(playerid,randmoney);
    
randomid onlineids[random(playersonline)];
    
GetPlayerName(randomidpname1sizeof(pname1));
    new 
str[200];
    
format(strsizeof(str),"{FF8C00}BONUS: {00B9FF}%s (%d) {FFFFFF}Has Been Selected As Bonus Player. Kill Him To Get {73FF00}$%d"pname1randomidrandmoney);
    
SendClientMessageToAll(-1str);
    
GameTextForAll("~w~ New Bonus Player.",30003);
    }
    return 
1;

This is the function the map start and work. But when the map start again i want to make it to show mee again the bonus.
Reply
#2

AnyOne?
Reply
#3

I don't understand how that code doesn't give you compile errors. "randomid" is never declared, so I assume it's a global variable.
The solution would be to make the "onlineids" and other variables static and right after the function "StartMap" declaration and before any other blocks so it exists all the time while the function runs.
Also you wouldn't need any of that code if you used foreach (or y_iterate) the right way.
Reply
#4

Please explain mee more good.
If you can with code
Reply
#5

Re-read the foreach (y_iterate) topic about getting a random player from the iterator.
Reply
#6

Omg i dont understand
Reply
#7

I think you do. Go and read THIS and simply use Iter_Random for getting a random player that is to receive a "prize".
Reply
#8

I dont understand it again. Please script for mee
Reply
#9

Bump.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)