a little error in my kill message script.
#1

I'm trying to make kill message script for a friend. The code is below:

PHP код:
#include <a_samp>
#include <JunkBuster>
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
    print(
"\n--------------------------------------");
    print(
" Blank Filterscript by your name here");
    print(
"--------------------------------------\n");
    return 
1;
}
#else
main()
{
    print(
"\n----------------------------------");
    print(
" Blank Gamemode by your name here");
    print(
"----------------------------------\n");
}
#endif
public OnPlayerDeath(playeridkilleridreason)
{
    new 
Text:Textdraw0//TextDraw
    
new Text:Textdraw1//TextDraw
    
new Text:Textdraw2;//TextDraw
    
new name[MAX_PLAYER_NAME];
    new 
killer[MAX_PLAYER_NAME];
    new 
weapname[50];
    new 
string0[128];
    new 
string1[128];
    new 
string2[128];
    
format(string0,128,"You were killed by %s. ",killer);
    
format(string1,128,"You killed %s.",name);
    
format(string2,128,"You commited suicide.");
    
GetPlayerName(playeridnamesizeof(name)); 
    
GetPlayerName(killeridkillersizeof(killer));
    
GetWeaponName(GetPlayerWeapon(killerid), weapnamesizeof(weapname));
    
Textdraw0 TextDrawCreate(257.333282143.111083string0);
    
TextDrawLetterSize(Textdraw00.2720001.284740);
    
TextDrawAlignment(Textdraw01);
    
TextDrawColor(Textdraw0, -1);
    
TextDrawSetShadow(Textdraw00);
    
TextDrawSetOutline(Textdraw01);
    
TextDrawBackgroundColor(Textdraw051);
    
TextDrawFont(Textdraw01);
    
TextDrawSetProportional(Textdraw01);
    
Textdraw1 TextDrawCreate(257.333282143.111083string1);
    
TextDrawLetterSize(Textdraw10.2720001.284740);
    
TextDrawAlignment(Textdraw11);
    
TextDrawColor(Textdraw1, -1);
    
TextDrawSetShadow(Textdraw10);
    
TextDrawSetOutline(Textdraw11);
    
TextDrawBackgroundColor(Textdraw151);
    
TextDrawFont(Textdraw11);
    
TextDrawSetProportional(Textdraw11);
    
Textdraw2 TextDrawCreate(257.333282143.111083string2);
    
TextDrawAlignment(Textdraw21);
    
TextDrawColor(Textdraw2, -1);
    
TextDrawSetShadow(Textdraw20);
    
TextDrawSetOutline(Textdraw21);
    
TextDrawBackgroundColor(Textdraw251);
    
TextDrawFont(Textdraw21);
    
TextDrawSetProportional(Textdraw21);
    if(
killerid != INVALID_PLAYER_ID)
        {
TextDrawShowForPlayer(playeridTextdraw2);}
    else    
    {
        
TextDrawShowForPlayer(playeridTextdraw0);
        
TextDrawShowForPlayer(killeridTextdraw1);
    }
    return 
1;
}
public 
OnPlayerSpawn(playerid
{
    
TextDrawHideForPlayer(playeridTextdraw0);//undefined symbol
    
TextDrawHideForPlayer(playeridTextdraw1);//undefined symbol
    
TextDrawHideForPlayer(playeridTextdraw2);//undefined symbol

the problem is, I get "undefined symbol" errors at the last lines under OnPlayerSpawn.
How can I bring back the symbols defined for another callback?
Reply
#2

Because the "new Text:Textdraw.." is declared inside a callback.
Put all of the text draw creation in OnGameModeInit and use TextDrawSetString inside the callback.
Reply
#3

This is a fs, so I used onfilterscriptinit. The same thing occured, but on both callbacks.
Reply
#4

pawn Код:
new Text:Textdraw0; //TextDraw
new Text:Textdraw1; //TextDraw
new Text:Textdraw2;//TextDraw
That, goes outside all callbacks. If you declare something inside a callback like you did with the variables above, then other callbacks can't access it directly. It would look like this if you change it:
pawn Код:
#include <a_samp>
#include <JunkBuster>
//====== GLOBAL VARIABLES HERE ======== //
    new Text:Textdraw0; //TextDraw
    new Text:Textdraw1; //TextDraw
    new Text:Textdraw2;//TextDraw
//
#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}
#else
main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}
#endif
public OnPlayerDeath(playerid, killerid, reason)
{

    new name[MAX_PLAYER_NAME];
    new killer[MAX_PLAYER_NAME];
    new weapname[50];

    new string0[128];
    new string1[128];
    new string2[128];

    format(string0,128,"You were killed by %s. ",killer);
    format(string1,128,"You killed %s.",name);
    format(string2,128,"You commited suicide.");

    GetPlayerName(playerid, name, sizeof(name));  
    GetPlayerName(killerid, killer, sizeof(killer));
    GetWeaponName(GetPlayerWeapon(killerid), weapname, sizeof(weapname));
    Textdraw0 = TextDrawCreate(257.333282, 143.111083, string0);
    TextDrawLetterSize(Textdraw0, 0.272000, 1.284740);
    TextDrawAlignment(Textdraw0, 1);
    TextDrawColor(Textdraw0, -1);
    TextDrawSetShadow(Textdraw0, 0);
    TextDrawSetOutline(Textdraw0, 1);
    TextDrawBackgroundColor(Textdraw0, 51);
    TextDrawFont(Textdraw0, 1);
    TextDrawSetProportional(Textdraw0, 1);

    Textdraw1 = TextDrawCreate(257.333282, 143.111083, string1);
    TextDrawLetterSize(Textdraw1, 0.272000, 1.284740);
    TextDrawAlignment(Textdraw1, 1);
    TextDrawColor(Textdraw1, -1);
    TextDrawSetShadow(Textdraw1, 0);
    TextDrawSetOutline(Textdraw1, 1);
    TextDrawBackgroundColor(Textdraw1, 51);
    TextDrawFont(Textdraw1, 1);
    TextDrawSetProportional(Textdraw1, 1);

    Textdraw2 = TextDrawCreate(257.333282, 143.111083, string2);
    TextDrawAlignment(Textdraw2, 1);
    TextDrawColor(Textdraw2, -1);
    TextDrawSetShadow(Textdraw2, 0);
    TextDrawSetOutline(Textdraw2, 1);
    TextDrawBackgroundColor(Textdraw2, 51);
    TextDrawFont(Textdraw2, 1);
    TextDrawSetProportional(Textdraw2, 1);

    if(killerid != INVALID_PLAYER_ID)
        {TextDrawShowForPlayer(playerid, Textdraw2);}
    else    
    {
        TextDrawShowForPlayer(playerid, Textdraw0);
        TextDrawShowForPlayer(killerid, Textdraw1);
    }
    return 1;
}
public OnPlayerSpawn(playerid)  
{
    TextDrawHideForPlayer(playerid, Textdraw0);//undefined symbol
    TextDrawHideForPlayer(playerid, Textdraw1);//undefined symbol
    TextDrawHideForPlayer(playerid, Textdraw2);//undefined symbol
}
If you need more clarification, feel free to ask
Reply
#5

I get it. Thanks, it worked. + rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)