3dtext
#5

PHP код:
#define MAX_LABELS 1000 // Change this to the limit of labels that can be created. Since you are using a streamer, there is no actual limit (I guess).
#define LABEL_FILE "labels.ini" // Label file name.
new Text3D:CreatedLabels[MAX_LABELS] = { Text3D:INVALID_3DTEXT_ID, ...};
public 
OnGameModeInit()
{
    
LoadSavedLabels(); // Loads every label from the labels file.
    
return 1;
}
CMD:tlabel(playeridparams[])
{
    new
        
Str[110];
    if(
sscanf(params"s[110]"Str)) return SendClientMessage(playerid, -1"Usage: /tlabel <text>");
    else
    {
        new 
idx;
        for(
idx 0idx MAX_LABELS; ++idx)
        {
            if(
CreatedLabels[idx] == Text3D:INVALID_3DTEXT_ID) break; // We find an empty ID.
        
}
        if(
idx == MAX_LABELS 1) return SendClientMessage(playerid, -1"Limit of labels reached."); // Limit reached.
        
new
            
Float:PosX,
            
Float:PosY,
            
Float:PosZ,
            
data[144]
        ;
        
GetPlayerPos(playeridPosXPosYPosZ);
        
CreatedLabels[idx] = CreateDynamic3DTextLabel(StrCOLOR_REDPosXPosYPosZ40.0);
        new 
File:fLabels fopen(LABEL_FILEio_append);
        if(
fLabels)
        {
            
format(datasizeof(data), "%f|%f|%f|%s\r\n"PosXPosYPosZStr);
            
fwrite(fLabelsdata);
            
fclose(fLabels);
            
            
format(Str110">> Label ID %d has been created successfully."idx);
            
SendClientMessage(playerid, -1Str);
        }else return 
SendClientMessage(playerid, -1"There has been an error while saving the label.");
    }
    return 
1;
}
LoadSavedLabels() // Function that loads the data.
{
    new 
File:fHandle fopen(LABEL_FILEio_read),
        
Data[144];
    if(
fHandle)
    {
        new 
idxStr[128], Float:lXFloat:lYFloat:lZ;
        while(
fread(fHandleData))
        {
            
sscanf(Data"p<|>fffs[144]"lXlYlZStr); // Split the data using sscanf.
            
CreatedLabels[idx] = CreateDynamic3DTextLabel(StrCOLOR_REDlXlYlZ40.0); // Creates the label.
            
++idx;
        }
        
fclose(fHandle);
        
printf("Total of labels created: %d"idx); // Debug.
    
}
    else
    {
        new 
File:uFile fopen(LABEL_FILEio_write); fclose(uFile);
        print(
"The file \""LABEL_FILE"\" does not exists, or can't be opened. File has been created by the system.");
    }
    return 
1;

Reply


Messages In This Thread
3dtext - by CSLangdale - 18.06.2016, 07:36
Re: 3dtext - by ToiletDuck - 18.06.2016, 11:17
Re: 3dtext - by TwinkiDaBoss - 18.06.2016, 12:46
Re: 3dtext - by CSLangdale - 20.06.2016, 15:02
Re: 3dtext - by Jf - 20.06.2016, 17:21
Re: 3dtext - by CSLangdale - 21.06.2016, 03:14
Re: 3dtext - by CSLangdale - 22.06.2016, 03:49

Forum Jump:


Users browsing this thread: 1 Guest(s)