Hello A LittLe Problem. -
arlindi - 13.08.2014
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(i, ServerIntroOne[i]);
TextDrawHideForPlayer(i, ServerIntroTwo[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=0; i<MAX_PLAYERS; i++) // 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*1000, 0);
}
}
randmoney = random(50000 - 1000) + 1000;
//GivePlayerMoney(playerid,randmoney);
randomid = onlineids[random(playersonline)];
GetPlayerName(randomid, pname1, sizeof(pname1));
new str[200];
format(str, sizeof(str),"{FF8C00}BONUS: {00B9FF}%s (%d) {FFFFFF}Has Been Selected As Bonus Player. Kill Him To Get {73FF00}$%d", pname1, randomid, randmoney);
SendClientMessageToAll(-1, str);
GameTextForAll("~w~ New Bonus Player.",3000, 3);
}
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.
Re: Hello A LittLe Problem. -
arlindi - 13.08.2014
AnyOne?
Re: Hello A LittLe Problem. -
Virtual1ty - 13.08.2014
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.
Re: Hello A LittLe Problem. -
arlindi - 13.08.2014
Please explain mee more good.
If you can with code
Re: Hello A LittLe Problem. -
Virtual1ty - 13.08.2014
Re-read the foreach (y_iterate) topic about getting a random player from the iterator.
Re: Hello A LittLe Problem. -
arlindi - 13.08.2014
Omg

i dont understand
Re: Hello A LittLe Problem. -
Virtual1ty - 13.08.2014
I think you do. Go and read
THIS and simply use Iter_Random for getting a random player that is to receive a "prize".
Re: Hello A LittLe Problem. -
arlindi - 13.08.2014
I dont understand it again. Please script for mee
Re: Hello A LittLe Problem. -
arlindi - 13.08.2014
Bump.