17.06.2010, 16:04
Aqui tens um exemplo jб em gamemode. Deve funcionar bem, mas de qualquer maneira й sу mudares ou perguntares aqui.
pawn Код:
#include <a_samp>
#if defined MAX_PLAYERS
#undef MAX_PLAYERS
#define MAX_PLAYERS (50) // Altera para o nъmero de slots do teu servidor.
#endif
new updatetxtd;
new timerupdate;
main()
{
}
public OnGameModeInit()
{
SetGameModeText("Example");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}
public OnGameModeExit()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
TextDrawHideForPlayer(i, Text:GetPVarInt(i, "MainBox"));
TextDrawHideForPlayer(i, Text:GetPVarInt(i, "SecondaryBox"));
TextDrawHideForPlayer(i, Text:GetPVarInt(i, "Percentage"));
TextDrawDestroy(Text:GetPVarInt(i, "MainBox"));
TextDrawDestroy(Text:GetPVarInt(i, "SecondaryBox"));
TextDrawDestroy(Text:GetPVarInt(i, "Percentage"));
DeletePVar(i, "MainBox");
DeletePVar(i, "SecondaryBox");
DeletePVar(i, "Percentage");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
_OnPlayerDisconnect(playerid);
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
TogglePlayerSpectating(playerid, 1);
_OnPlayerConnect(playerid);
TextDrawShowForPlayer(playerid, Text:GetPVarInt(playerid, "MainBox"));
TextDrawShowForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));
TextDrawShowForPlayer(playerid, Text:GetPVarInt(playerid, "Percentage"));
timerupdate = SetTimerEx("Update", 3000, true, "%d", playerid);
return 1;
}
forward Update(playerid);
public Update(playerid)
{
updatetxtd++;
if(updatetxtd == 1)
{
TextDrawHideForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));
TextDrawTextSize(Text:GetPVarInt(playerid, "SecondaryBox"), 234.000000+20, -1.000000);
TextDrawShowForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));
TextDrawSetString(Text:GetPVarInt(playerid, "Percentage"), "20 %");
}
else if(updatetxtd == 2)
{
TextDrawHideForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));
TextDrawTextSize(Text:GetPVarInt(playerid, "SecondaryBox"), 234.000000+40, -1.000000);
TextDrawShowForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));
TextDrawSetString(Text:GetPVarInt(playerid, "Percentage"), "40 %");
}
else if(updatetxtd == 3)
{
TextDrawHideForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));
TextDrawTextSize(Text:GetPVarInt(playerid, "SecondaryBox"), 234.000000+60, -1.000000);
TextDrawShowForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));
TextDrawSetString(Text:GetPVarInt(playerid, "Percentage"), "60 %");
}
else if(updatetxtd == 4)
{
TextDrawHideForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));
TextDrawTextSize(Text:GetPVarInt(playerid, "SecondaryBox"), 234.000000+80, -1.000000);
TextDrawShowForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));
TextDrawSetString(Text:GetPVarInt(playerid, "Percentage"), "80 %");
}
else if(updatetxtd == 5)
{
TextDrawHideForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));
TextDrawTextSize(Text:GetPVarInt(playerid, "SecondaryBox"), 234.000000+100+2, -1.000000);
TextDrawShowForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));
TextDrawSetString(Text:GetPVarInt(playerid, "Percentage"), "100 %");
GameTextForPlayer(playerid, "A preparar as coisas...", 2000, 5);
}
else if(updatetxtd == 6)
{
_OnPlayerDisconnect(playerid);
updatetxtd = 0;
TogglePlayerSpectating(playerid, 0);
SpawnPlayer(playerid);
}
return 1;
}
stock _OnPlayerConnect(playerid)
{
SetPVarInt(playerid, "MainBox", _:TextDrawCreate(339.000000, 381.000000, "_"));
TextDrawUseBox(Text:GetPVarInt(playerid, "MainBox"), 1);
TextDrawBoxColor(Text:GetPVarInt(playerid, "MainBox"), 1095626832);
TextDrawTextSize(Text:GetPVarInt(playerid, "MainBox"), 234.000000, -1.000000);
SetPVarInt(playerid, "SecondaryBox", _:TextDrawCreate(236.000000, 381.000000, "_"));
TextDrawUseBox(Text:GetPVarInt(playerid, "SecondaryBox"), 1);
TextDrawBoxColor(Text:GetPVarInt(playerid, "SecondaryBox"), 270392319);
TextDrawTextSize(Text:GetPVarInt(playerid, "SecondaryBox"), 234.000000, -1.000000);
SetPVarInt(playerid, "Percentage", _:TextDrawCreate(339.000000, 381.000000, "0 %"));
TextDrawBackgroundColor(Text:GetPVarInt(playerid, "Percentage"), 255);
TextDrawFont(Text:GetPVarInt(playerid, "Percentage"), 3);
TextDrawLetterSize(Text:GetPVarInt(playerid, "Percentage"), 0.210000, 1.000000);
TextDrawColor(Text:GetPVarInt(playerid, "Percentage"), -1);
TextDrawSetOutline(Text:GetPVarInt(playerid, "Percentage"), 1);
TextDrawSetProportional(Text:GetPVarInt(playerid, "Percentage"), 0);
}
stock _OnPlayerDisconnect(playerid)
{
KillTimer(timerupdate);
TextDrawHideForPlayer(playerid, Text:GetPVarInt(playerid, "MainBox"));
TextDrawHideForPlayer(playerid, Text:GetPVarInt(playerid, "SecondaryBox"));
TextDrawHideForPlayer(playerid, Text:GetPVarInt(playerid, "Percentage"));
TextDrawDestroy(Text:GetPVarInt(playerid, "MainBox"));
TextDrawDestroy(Text:GetPVarInt(playerid, "SecondaryBox"));
TextDrawDestroy(Text:GetPVarInt(playerid, "Percentage"));
DeletePVar(playerid, "MainBox");
DeletePVar(playerid, "SecondaryBox");
DeletePVar(playerid, "Percentage");
}