Text above player script doesn't work for me
#1

Hello can someone correct me ?

#include <a_samp>
if (strcmp("/text", cmdtext, true, 10) == 0)
{
new Text3D:label = Create3DTextLabel("Text above player", 0x002020FF, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(label, playerid, 0.0, 0.0, 0.7);
return 1;
}

Whenever i save this as an .amx and add that filterscript to server.cfg it instantly crashes :/
(by the way, it is only this script, nothing more, nothing less)
Reply
#2

Consider using SetPlayerChatBubble for this purpose instead, as it works the same way to seem to be attempting to use it.

EDIT: Also, you must add #define FILTERSCRIPT under the first line in order for the compiler to compile it as a Filterscript and not as a Gamemode. This is probably why it crashes.
Reply
#3

Thanks for the quick reply ! Well, I don't think that I really need SetPlayerChatBubble , I want a label above player's nickname attached to the player. So let's say I'm an administrator and I want "Administrator" above my name. And I've come to this:

#include <a_samp>
#define FILTERSCRIPT
if (strcmp("/text", cmdtext, true, 10) == 0)
{
new Text3D:label = Create3DTextLabel("Text above player", 0x002020FF, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(label, playerid, 0.0, 0.0, 0.7);
return 1;
}

But it still crashes ! Any ideas ?
Reply
#4

Your Create3DTextLabel is missing a parameter, though I doubt that's the reason of the crash. (Example). Just add a , 0 to the end of it.

Try to do #define FILTERSCRIPT at the very top, above the include.

Also, that "if" statement should be within the OnPlayerText callback, so the game knows when to run it.

This is how your code should look (i think, cannot test atm).

pawn Code:
#define FILTERSCRIPT
#include <a_samp>
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/text", cmdtext, true, 10) == 0)
    {
        new Text3D:label = Create3DTextLabel("Text above player", 0x002020FF, 30.0, 40.0, 50.0, 40.0, 0);
        Attach3DTextLabelToPlayer(label, playerid, 0.0, 0.0, 0.7);
        return 1;
    }
}
Reply
#5

#define FILTERSCRIPT
#include <a_samp>
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/text", cmdtext, true, 10) == 0)
{
new Text3D:label = Create3DTextLabel("Text above player", 0x002020FF, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(label, playerid, 0.0, 0.0, 0.7);
return 1;
}
return 0;
}

You forgot return 0; :P But thanks a LOT man ! This is my first ever script made and I am so excited !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)