1. Pentru inceput avem de creat urmatoarele new's:
new Text3D:HouseLabel[MAX_PLAYERS]; // House Text3Dnew pickuptimer; 2. In al doilea pas avem de creat cateva forward's:
forward CustomPickups();forward GameModeExitFunc();forward GameModeInitExitFunc(); 3. Acum vom crea 3D textul cu ajutorul functiei forward CustomPickups();:
//-----------------------------== 3DTextLabel House ==--------------------------------------public CustomPickups(){ new Float:oldposx, Float:oldposy, Float:oldposz; new string[128]; for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { GetPlayerPos(i, oldposx, oldposy, oldposz); if(oldposx!=0.0 && oldposy!=0.0 && oldposz!=0.0) { for(new h = 0; h < sizeof(HouseInfo); h++) { if(PlayerToPoint(2.0, i, HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez])) { if(HouseInfo[h][hOwned] == 1) { if(HouseInfo[h][hRentabil] == 0) { Delete3DTextLabel(Text3D:HouseLabel[h]); format(string, sizeof(string), "Owner: %s \n Level: %d",HouseInfo[h][hOwner],HouseInfo[h][hLevel]); HouseLabel[h] = Create3DTextLabel(string ,0xE60000FF,HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]+1,8,0,1); } else { Delete3DTextLabel(Text3D:HouseLabel[h]); format(string, sizeof(string), "Avabile for rent, Owner: %s \n Rent: %d$ Level: %d \n Type [/rentroom].",HouseInfo[h][hOwner],HouseInfo[h][hRent],HouseInfo[h][hLevel]); HouseLabel[h] = Create3DTextLabel(string ,0xE60000FF,HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]+1,8,0,1); } return 1; } else { Delete3DTextLabel(Text3D:HouseLabel[h]); format(string,sizeof(string),"Property for sale \n Price: %d$ Level: %d\nCommand: /buyhouse",HouseInfo[h][hValue],HouseInfo[h][hLevel]); HouseLabel[h] = Create3DTextLabel(string ,0xE60000FF,HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]+1,8,0,1); } return 1; } } } } } return 1;}
4. Mergem la public OnGameModeInit() si adaugam:
pickuptimer = SetTimer("CustomPickups", 1000, 1);//undeva pe la sfarsitul functiei
5. Pentru a putea fi in timp real update-ul la 3DTextLabel vom folosi functia GameModeExitFunc() si va fi de genul:
public GameModeExitFunc(){ KillTimer(pickuptimer);}
6. In continuare pentru a functiona cum trebuie update-ul vom folosi functia GameModeInitExitFunc():
public GameModeInitExitFunc() //aceasta functie o folosesc pentru restartul serverului (/restart){ new string[128]; format(string, sizeof(string), "Traveling..."); for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { DisablePlayerCheckpoint(i); gPlayerCheckpointStatus[i] = CHECKPOINT_NONE; GameTextForPlayer(i, string, 4000, 5); SetPlayerCameraPos(i,1460.0, -1324.0, 287.2); SetPlayerCameraLookAt(i,1374.5, -1291.1, 239.0); SavePlayerData(i); gPlayerLogged[i] = 0; } } SetTimer("GameModeExitFunc", 4000, 0); return 1;}
8. In final pentru cine are nevoie de comanda /restart, o voi posta mai jos:
if(strcmp(cmd, "/restart", true) == 0) { if(IsPlayerConnected(playerid)) { if (PlayerInfo[playerid][pAdmin] >= 1339) { GameModeInitExitFunc(); } else { SendClientMessage(playerid, 0xC0764FFF, "[DENIED]: " #COL_YELLOW2"You are not authorized to use that command!"); } } return 1; }
Sursa:www.egaming.ro
Ultima editare efectuata de catre Ducadam in Vin Noi 02, 2012 12:46 am, editata de 1 ori
new Text3D:HouseLabel[MAX_PLAYERS]; // House Text3Dnew pickuptimer; 2. In al doilea pas avem de creat cateva forward's:
forward CustomPickups();forward GameModeExitFunc();forward GameModeInitExitFunc(); 3. Acum vom crea 3D textul cu ajutorul functiei forward CustomPickups();:
//-----------------------------== 3DTextLabel House ==--------------------------------------public CustomPickups(){ new Float:oldposx, Float:oldposy, Float:oldposz; new string[128]; for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { GetPlayerPos(i, oldposx, oldposy, oldposz); if(oldposx!=0.0 && oldposy!=0.0 && oldposz!=0.0) { for(new h = 0; h < sizeof(HouseInfo); h++) { if(PlayerToPoint(2.0, i, HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez])) { if(HouseInfo[h][hOwned] == 1) { if(HouseInfo[h][hRentabil] == 0) { Delete3DTextLabel(Text3D:HouseLabel[h]); format(string, sizeof(string), "Owner: %s \n Level: %d",HouseInfo[h][hOwner],HouseInfo[h][hLevel]); HouseLabel[h] = Create3DTextLabel(string ,0xE60000FF,HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]+1,8,0,1); } else { Delete3DTextLabel(Text3D:HouseLabel[h]); format(string, sizeof(string), "Avabile for rent, Owner: %s \n Rent: %d$ Level: %d \n Type [/rentroom].",HouseInfo[h][hOwner],HouseInfo[h][hRent],HouseInfo[h][hLevel]); HouseLabel[h] = Create3DTextLabel(string ,0xE60000FF,HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]+1,8,0,1); } return 1; } else { Delete3DTextLabel(Text3D:HouseLabel[h]); format(string,sizeof(string),"Property for sale \n Price: %d$ Level: %d\nCommand: /buyhouse",HouseInfo[h][hValue],HouseInfo[h][hLevel]); HouseLabel[h] = Create3DTextLabel(string ,0xE60000FF,HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]+1,8,0,1); } return 1; } } } } } return 1;}
4. Mergem la public OnGameModeInit() si adaugam:
pickuptimer = SetTimer("CustomPickups", 1000, 1);//undeva pe la sfarsitul functiei
5. Pentru a putea fi in timp real update-ul la 3DTextLabel vom folosi functia GameModeExitFunc() si va fi de genul:
public GameModeExitFunc(){ KillTimer(pickuptimer);}
6. In continuare pentru a functiona cum trebuie update-ul vom folosi functia GameModeInitExitFunc():
public GameModeInitExitFunc() //aceasta functie o folosesc pentru restartul serverului (/restart){ new string[128]; format(string, sizeof(string), "Traveling..."); for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { DisablePlayerCheckpoint(i); gPlayerCheckpointStatus[i] = CHECKPOINT_NONE; GameTextForPlayer(i, string, 4000, 5); SetPlayerCameraPos(i,1460.0, -1324.0, 287.2); SetPlayerCameraLookAt(i,1374.5, -1291.1, 239.0); SavePlayerData(i); gPlayerLogged[i] = 0; } } SetTimer("GameModeExitFunc", 4000, 0); return 1;}
8. In final pentru cine are nevoie de comanda /restart, o voi posta mai jos:
if(strcmp(cmd, "/restart", true) == 0) { if(IsPlayerConnected(playerid)) { if (PlayerInfo[playerid][pAdmin] >= 1339) { GameModeInitExitFunc(); } else { SendClientMessage(playerid, 0xC0764FFF, "[DENIED]: " #COL_YELLOW2"You are not authorized to use that command!"); } } return 1; }
Sursa:www.egaming.ro
Ultima editare efectuata de catre Ducadam in Vin Noi 02, 2012 12:46 am, editata de 1 ori