|
Originally Posted by saiberfun
Thanks and wat do i put as string?
|
public Draw()
{
new str[128];
for(new i; i<MAX_PLAYERS; i++)
{
if(draw[i] == 0)
{
format(str, sizeof str, "Hours:%d Mins:%d Secs:%d",AccountInfo[i][Hours],AccountInfo[i][Mins],AccountInfo[i][Secs]);
Textdraw0 = TextDrawCreate(303.000000,432.000000,str);
TextDrawAlignment(Textdraw0,0);
TextDrawBackgroundColor(Textdraw0,0x000000ff);
TextDrawFont(Textdraw0,3);
TextDrawLetterSize(Textdraw0,0.699999,1.200000);
TextDrawColor(Textdraw0,0xffffffff);
TextDrawSetOutline(Textdraw0,1);
TextDrawSetProportional(Textdraw0,1);
TextDrawSetShadow(Textdraw0,1);
TextDrawShowForPlayer(i,Textdraw0);
draw[i] = 1;
}
if(draw[i] == 1)
{
TextDrawSetString(Textdraw0,str);
}
}
return 1;
}

|
Originally Posted by saiberfun
pawn Код:
but it does crash my server ![]() the timer is set to 1sec aka 1000ms |
|
Originally Posted by lesley
OnFilterScriptInit: create a textdraw for all players using a loop
OnPlayerConnect/Login: TextDrawShowForPlayer OnPlayerDisconnect: TextDrawHideForPlayer and to change the text in it (in the timer): TextDrawSetString |
#include <a_samp>
enum PlayerInfoEnum {
Text:PlayingTime,
bool:TextOn,
Time
};
new PlayerInfo[200][PlayerInfoEnum];
public OnFilterScriptInit()
{
SetTimer("Draw",1000,1);
for(new i=0; i < GetMaxPlayers(); i++) {
CreatePlayerDraw(i);
if(IsPlayerConnected(i)) {
TextDrawShowForPlayer(i,PlayerInfo[i][PlayingTime]);
}
}
return 1;
}
public OnFilterScriptExit()
{
for(new i=0; i < GetMaxPlayers(); i++) {
DestroyPlayerDraw(i);
}
return 1;
}
public OnPlayerConnect(playerid)
{
CreatePlayerDraw(playerid);
PlayerInfo[playerid][Time]=0;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
DestroyPlayerDraw(playerid);
PlayerInfo[playerid][Time]=0;
return 1;
}
forward Draw();
public Draw()
{
new str[128];
for(new i=0; i<GetMaxPlayers(); i++)
{
PlayerInfo[i][Time]++;
format(str, sizeof str, "Hours:%d Mins:%d Secs:%d",PlayerInfo[i][Time]/3600,PlayerInfo[i][Time]/60-(((PlayerInfo[i][Time]/3600)*3600)/60),PlayerInfo[i][Time]-((PlayerInfo[i][Time]/60)*60));
TextDrawSetString(PlayerInfo[i][PlayingTime],str);
SetPlayerScore(i,PlayerInfo[i][Time]/3600);
}
return 1;
}
stock CreatePlayerDraw(playerid){
if(!PlayerInfo[playerid][TextOn]) {
PlayerInfo[playerid][TextOn]=true;
PlayerInfo[playerid][PlayingTime] = TextDrawCreate(303.0,432.0,"_");
TextDrawAlignment(PlayerInfo[playerid][PlayingTime],0);
TextDrawBackgroundColor(PlayerInfo[playerid][PlayingTime],0x000000ff);
TextDrawFont(PlayerInfo[playerid][PlayingTime],3);
TextDrawLetterSize(PlayerInfo[playerid][PlayingTime],0.7,1.2);
TextDrawColor(PlayerInfo[playerid][PlayingTime],0xffffffff);
TextDrawSetOutline(PlayerInfo[playerid][PlayingTime],1);
TextDrawSetProportional(PlayerInfo[playerid][PlayingTime],1);
TextDrawSetShadow(PlayerInfo[playerid][PlayingTime],1);
TextDrawShowForPlayer(playerid,PlayerInfo[playerid][PlayingTime]);
}
return 1;
}
stock DestroyPlayerDraw(playerid){
if(PlayerInfo[playerid][TextOn]) {
TextDrawHideForPlayer(playerid,PlayerInfo[playerid][PlayingTime]);
PlayerInfo[playerid][TextOn]=false;
TextDrawDestroy(PlayerInfo[playerid][PlayingTime]);
}
return 1;
}
|
Originally Posted by Jefff
FilterScript and learn it :P
Код:
#include <a_samp>
enum PlayerInfoEnum {
Text:PlayingTime,
bool:TextOn,
Time
};
new PlayerInfo[200][PlayerInfoEnum];
public OnFilterScriptInit()
{
SetTimer("Draw",1000,1);
for(new i=0; i < GetMaxPlayers(); i++) {
CreatePlayerDraw(i);
if(IsPlayerConnected(i)) {
TextDrawShowForPlayer(i,PlayerInfo[i][PlayingTime]);
}
}
return 1;
}
public OnFilterScriptExit()
{
for(new i=0; i < GetMaxPlayers(); i++) {
DestroyPlayerDraw(i);
}
return 1;
}
public OnPlayerConnect(playerid)
{
CreatePlayerDraw(playerid);
PlayerInfo[playerid][Time]=0;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
DestroyPlayerDraw(playerid);
PlayerInfo[playerid][Time]=0;
return 1;
}
forward Draw();
public Draw()
{
new str[128];
for(new i=0; i<GetMaxPlayers(); i++)
{
PlayerInfo[i][Time]++;
format(str, sizeof str, "Hours:%d Mins:%d Secs:%d",PlayerInfo[i][Time]/3600,PlayerInfo[i][Time]/60-(((PlayerInfo[i][Time]/3600)*3600)/60),PlayerInfo[i][Time]-((PlayerInfo[i][Time]/60)*60));
TextDrawSetString(PlayerInfo[i][PlayingTime],str);
SetPlayerScore(i,PlayerInfo[i][Time]/3600);
}
return 1;
}
stock CreatePlayerDraw(playerid){
if(!PlayerInfo[playerid][TextOn]) {
PlayerInfo[playerid][TextOn]=true;
PlayerInfo[playerid][PlayingTime] = TextDrawCreate(303.0,432.0,"_");
TextDrawAlignment(PlayerInfo[playerid][PlayingTime],0);
TextDrawBackgroundColor(PlayerInfo[playerid][PlayingTime],0x000000ff);
TextDrawFont(PlayerInfo[playerid][PlayingTime],3);
TextDrawLetterSize(PlayerInfo[playerid][PlayingTime],0.7,1.2);
TextDrawColor(PlayerInfo[playerid][PlayingTime],0xffffffff);
TextDrawSetOutline(PlayerInfo[playerid][PlayingTime],1);
TextDrawSetProportional(PlayerInfo[playerid][PlayingTime],1);
TextDrawSetShadow(PlayerInfo[playerid][PlayingTime],1);
TextDrawShowForPlayer(playerid,PlayerInfo[playerid][PlayingTime]);
}
return 1;
}
stock DestroyPlayerDraw(playerid){
if(PlayerInfo[playerid][TextOn]) {
TextDrawHideForPlayer(playerid,PlayerInfo[playerid][PlayingTime]);
PlayerInfo[playerid][TextOn]=false;
TextDrawDestroy(PlayerInfo[playerid][PlayingTime]);
}
return 1;
}
|