SA-MP Forums Archive
Help me to add these lines under ongamemodeinit(); - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help me to add these lines under ongamemodeinit(); (/showthread.php?tid=215581)



Help me to add these lines under ongamemodeinit(); - WardenCS - 23.01.2011

Hello,i need help,i want to add some lines to under gamemodeinit,i mean like when the gamemode loads,it will load houses from every player

Код:
		if(PlayerInfo[playerid][pHouseAccepted] > 0)
		{
		    print("///   CREATE HOUSE   ///");
            printf("PlayerID: %d", playerid);
		    new hnametag[64];
		    new hloctag[64];
		    //pickup
			HousePickupIDTemp[playerid] = CreatePickup(1273,1,PlayerInfo[playerid][pHouseX],PlayerInfo[playerid][pHouseY],PlayerInfo[playerid][pHouseZ]);
			printf("PickupID: %d", HousePickupIDTemp[playerid]);
		    //nametag
		    strmid(hnametag, PlayerInfo[playerid][pHouseTag], 0, strlen(PlayerInfo[playerid][pHouseTag]), 255);
			House3dTextID[playerid] = Create3DTextLabel(hnametag,COLOR_HOUSETEXT,PlayerInfo[playerid][pHouseX],PlayerInfo[playerid][pHouseY],PlayerInfo[playerid][pHouseZ]+0.88,20.0,0,1);
			printf("House3dTextID: %d", _:House3dTextID[playerid]);
			//owner
			new string[256];
			format(string, sizeof(string),"Owner: %s", PlayerName(playerid));
			HouseTextOwnerID[playerid] = Create3DTextLabel(string,COLOR_HOUSETEXT,PlayerInfo[playerid][pHouseX],PlayerInfo[playerid][pHouseY],PlayerInfo[playerid][pHouseZ]+0.74,20.0,0,1);
			strmid(PlayerInfo[playerid][pHouseOwnerTag], PlayerName(playerid), 0, strlen(PlayerName(playerid)), 255);
			printf("HouseTextOwnerID: %d", _:HouseTextOwnerID[playerid]);
			//location
			strmid(hloctag, PlayerInfo[playerid][pHouseLocTag], 0, strlen(PlayerInfo[playerid][pHouseLocTag]), 255);
			format(string, sizeof(string),"Location: %s", hloctag);
			HouseTextLocationID[playerid] = Create3DTextLabel(string,COLOR_HOUSETEXT,PlayerInfo[playerid][pHouseX],PlayerInfo[playerid][pHouseY],PlayerInfo[playerid][pHouseZ]+0.60,20.0,0,1);
			printf("HouseTextLocationID: %d", _:HouseTextLocationID[playerid]);
			//vehicle
			HouseVehicleIDTemp[playerid] = CreateVehicle(PlayerInfo[playerid][pHouseCarModel],PlayerInfo[playerid][pHouseCarX],PlayerInfo[playerid][pHouseCarY],PlayerInfo[playerid][pHouseCarZ],PlayerInfo[playerid][pHouseCarFacing],PlayerInfo[playerid][pHouseCarColor],PlayerInfo[playerid][pHouseCarColor2], 900);
			if(PlayerInfo[playerid][hVehLock] > 0)
			{
				LockCar(HouseVehicleIDTemp[playerid]);
			}
			printf("VehicleID: %d", HouseVehicleIDTemp[playerid]);
			print("///   CREATE HOUSE END   ///");
		}
		else
		{
		    ClearHouseInfo(playerid);
		}



Re: Help me to add these lines under ongamemodeinit(); - Marricio - 23.01.2011

''playerid'' cant be used in OnGameModeInit.


Re: Help me to add these lines under ongamemodeinit(); - blackwave - 23.01.2011

Unless you're reloading the server, this functions would have sense to be used there. As marricio said, can't be used on OnGameModeInit. But you could check the players which have these conditions, and process the information. Like:
pawn Код:
for(new v; v < MAX_PLAYERS; v++)
{
    if(IsPlayerConnected(v))
    {
              // Put the function here, and change all "playerid" for "v"
    }
}
Also, for be faster, foreach ****** inc would be good