SA-MP Forums Archive
need help with this script - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: need help with this script (/showthread.php?tid=249565)



need help with this script - XrespenserX - 19.04.2011

HI all im stucked with this script. Its acutelly a scoreboard showing the rank and score of the player

pawn Код:
#include <a_samp>

new Text:Textdraw0;
new Text:Textdraw1;
new Text:Textdraw2;
new rank[ MAX_PLAYERS ];

public OnFilterScriptInit()
{
    Textdraw0 = TextDrawCreate(414.000000, 404.000000, "Score:~r~");
    TextDrawBackgroundColor(Textdraw0, 16711935);
    TextDrawFont(Textdraw0, 2);
    TextDrawLetterSize(Textdraw0, 0.529999, 2.599999);
    TextDrawColor(Textdraw0, 65535);
    TextDrawSetOutline(Textdraw0, 1);
    TextDrawSetProportional(Textdraw0, 1);

    Textdraw2 = TextDrawCreate(414.000000, 384.000000, "Rank:~r~");
    TextDrawBackgroundColor(Textdraw2, 16711935);
    TextDrawFont(Textdraw2, 2);
    TextDrawLetterSize(Textdraw2, 0.570000, 2.700000);
    TextDrawColor(Textdraw2, 65535);
    TextDrawSetOutline(Textdraw2, 1);
    TextDrawSetProportional(Textdraw2, 1);
    return 1;
}

public OnPlayerSpawn( playerid )
{
    TextDrawShowForPlayer( playerid, Textdraw0 );
    TextDrawShowForPlayer( playerid, Textdraw1 );
    TextDrawShowForPlayer( playerid, Textdraw2 );
    return 1;
}

public OnPlayerUpdate( playerid )
{
    new string[ 128 ];
    new score;
    score = GetPlayerScore(playerid);
    format( string, sizeof string, "Score:~r~ %d", score );
    TextDrawSetString(Textdraw0, string);

    if(GetPlayerScore(playerid) >= 1000) rank[ playerid ] = (500, 100, "General");
    else if(GetPlayerScore(playerid) >= 700) rank[ playerid ] = (500, 100, "Captain");
    else if(GetPlayerScore(playerid) >= 500) rank[ playerid ] = (500, 100, "Lieutenant");
    else if(GetPlayerScore(playerid) >= 200) rank[ playerid ] = (500, 100, "Sergeant");
    else if(GetPlayerScore(playerid) >= 100) rank[ playerid ] = (500, 100, "Corporal");
    else if(GetPlayerScore(playerid) >= 50) rank[ playerid ] = (500, 100, "Privat First Class");
    else if(GetPlayerScore(playerid) >= 0) rank[ playerid ] = (500, 100, "Privat");
    format( string, sizeof string, "Rank:~r~ %d", rank[ playerid ] );
    TextDrawSetString( Textdraw2, string );
    return 1;
}
im getting this errors

pawn Код:
C:\Users\Admin\Desktop\COD9 - Battlefield\filterscripts\ranking.pwn(44) : error 006: must be assigned to an array
C:\Users\Admin\Desktop\COD9 - Battlefield\filterscripts\ranking.pwn(45) : error 006: must be assigned to an array
C:\Users\Admin\Desktop\COD9 - Battlefield\filterscripts\ranking.pwn(46) : error 006: must be assigned to an array
C:\Users\Admin\Desktop\COD9 - Battlefield\filterscripts\ranking.pwn(47) : error 006: must be assigned to an array
C:\Users\Admin\Desktop\COD9 - Battlefield\filterscripts\ranking.pwn(48) : error 006: must be assigned to an array
C:\Users\Admin\Desktop\COD9 - Battlefield\filterscripts\ranking.pwn(49) : error 006: must be assigned to an array
C:\Users\Admin\Desktop\COD9 - Battlefield\filterscripts\ranking.pwn(50) : error 006: must be assigned to an array
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


7 Errors.
can anyone help me? pls i need to fix it soon as possible

thanks

xRx


Re: need help with this script - s0nic - 19.04.2011

Well before someone helps you with those errors..
I gotta tell you that how your setting up your textdraws will not work for all the players as it will be showing someone else's score each time it updates..you need to learn how to create Textdraws for individual players
Heres a small example:
pawn Код:
new Text:Textdraw0[MAX_PLAYERS];

//Probably OnPlayerConnect for you
    Textdraw0[playerid] = TextDrawCreate(414.000000, 404.000000, "Score:~r~");
    TextDrawBackgroundColor(Textdraw0[playerid], 16711935);
    TextDrawFont(Textdraw0[playerid], 2);
    TextDrawLetterSize(Textdraw0[playerid], 0.529999, 2.599999);
    TextDrawColor(Textdraw0[playerid], 65535);
    TextDrawSetOutline(Textdraw0[playerid], 1);
    TextDrawSetProportional(Textdraw0[playerid], 1);



Re: need help with this script - Niko_boy - 19.04.2011

where is text draw 1.

also text draws are supposed to keep on top of script.
like where there are defines.


AW: Re: need help with this script - XrespenserX - 19.04.2011

Quote:
Originally Posted by s0nic
Посмотреть сообщение
Well before someone helps you with those errors..
I gotta tell you that how your setting up your textdraws will not work for all the players as it will be showing someone else's score each time it updates..you need to learn how to create Textdraws for individual players
Heres a small example:
pawn Код:
new Text:Textdraw0[MAX_PLAYERS];

//Probably OnPlayerConnect for you
    Textdraw0[playerid] = TextDrawCreate(414.000000, 404.000000, "Score:~r~");
    TextDrawBackgroundColor(Textdraw0[playerid], 16711935);
    TextDrawFont(Textdraw0[playerid], 2);
    TextDrawLetterSize(Textdraw0[playerid], 0.529999, 2.599999);
    TextDrawColor(Textdraw0[playerid], 65535);
    TextDrawSetOutline(Textdraw0[playerid], 1);
    TextDrawSetProportional(Textdraw0[playerid], 1);
can you fix this script pls? Im a small scripter and dunno how to fix it correctly..


Re: need help with this script - Joe Staff - 19.04.2011

Quote:
Originally Posted by s0nic
Посмотреть сообщение
Well before someone helps you with those errors..
I gotta tell you that how your setting up your textdraws will not work for all the players as it will be showing someone else's score each time it updates..you need to learn how to create Textdraws for individual players
Heres a small example:
pawn Код:
new Text:Textdraw0[MAX_PLAYERS];

//Probably OnPlayerConnect for you
    Textdraw0[playerid] = TextDrawCreate(414.000000, 404.000000, "Score:~r~");
    TextDrawBackgroundColor(Textdraw0[playerid], 16711935);
    TextDrawFont(Textdraw0[playerid], 2);
    TextDrawLetterSize(Textdraw0[playerid], 0.529999, 2.599999);
    TextDrawColor(Textdraw0[playerid], 65535);
    TextDrawSetOutline(Textdraw0[playerid], 1);
    TextDrawSetProportional(Textdraw0[playerid], 1);
You should only do that to textdraws that are unique to the player, textdraw0 will be the same for all players, no sense in creating it 500 times


Re: need help with this script - XrespenserX - 19.04.2011

can anyone correct the script pls ?


Re: need help with this script - s0nic - 19.04.2011

Here ya go:
pawn Код:
#include <a_samp>

new Text:_score[MAX_PLAYERS];
new Text:_rank[MAX_PLAYERS];
new rank[MAX_PLAYERS][20];

public OnFilterScriptInit()
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    _score[playerid] = TextDrawCreate(414.000000, 404.000000, "Score:~r~");
    TextDrawBackgroundColor(_score[playerid], 16711935);
    TextDrawFont(_score[playerid], 2);
    TextDrawLetterSize(_score[playerid], 0.529999, 2.599999);
    TextDrawColor(_score[playerid], 65535);
    TextDrawSetOutline(_score[playerid], 1);
    TextDrawSetProportional(_score[playerid], 1);
   
    _rank[playerid] = TextDrawCreate(414.000000, 384.000000, "Rank:~r~");
    TextDrawBackgroundColor(_rank[playerid], 16711935);
    TextDrawFont(_rank[playerid], 2);
    TextDrawLetterSize(_rank[playerid], 0.570000, 2.700000);
    TextDrawColor(_rank[playerid], 65535);
    TextDrawSetOutline(_rank[playerid], 1);
    TextDrawSetProportional(_rank[playerid], 1);
}

public OnPlayerDisconnect(playerid)
{
    TextDrawHideForPlayer(playerid, _score[playerid]);
    TextDrawHideForPlayer(playerid, _rank[playerid]);
    TextDrawDestroy(_score[playerid]);
    TextDrawDestroy(_rank[playerid]);
}

public OnPlayerSpawn(playerid)
{
    TextDrawShowForPlayer( playerid, _score[playerid]);
    TextDrawShowForPlayer( playerid, _rank[playerid]);
    return 1;
}

public OnPlayerUpdate(playerid)
{
    new string[128];
    new score = GetPlayerScore(playerid);
    format(string, sizeof(string), "Score:~r~ %d", score);
    TextDrawSetString(_score[playerid], string);
   
    if(GetPlayerScore(playerid) >= 1000) rank[playerid]     = (500, 100, "General");
    else if(GetPlayerScore(playerid) >= 700) rank[playerid] = (500, 100, "Captain");
    else if(GetPlayerScore(playerid) >= 500) rank[playerid] = (500, 100, "Lieutenant");
    else if(GetPlayerScore(playerid) >= 200) rank[playerid] = (500, 100, "Sergeant");
    else if(GetPlayerScore(playerid) >= 100) rank[playerid] = (500, 100, "Corporal");
    else if(GetPlayerScore(playerid) >= 50) rank[playerid]  = (500, 100, "Private First Class");
    else if(GetPlayerScore(playerid) >= 0) rank[playerid]   = (500, 100, "Private");
    format( string, sizeof string, "Rank:~r~ %d", rank[playerid]);
    TextDrawSetString(_rank[playerid], string);
    return 1;
}
Not sure why it compiles because wtf is this:
(500, 100, " ")
Quote:
Originally Posted by SilentHuntR
Посмотреть сообщение
You should only do that to textdraws that are unique to the player, textdraw0 will be the same for all players, no sense in creating it 500 times
Not sure if you read it thoroughly but it is unique to the player and its not creating it 500 times as its actually being created when the player connects


Re: need help with this script - XrespenserX - 20.04.2011

Quote:
Originally Posted by s0nic
Посмотреть сообщение
Here ya go:
pawn Код:
#include <a_samp>

new Text:_score[MAX_PLAYERS];
new Text:_rank[MAX_PLAYERS];
new rank[MAX_PLAYERS][20];

public OnFilterScriptInit()
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    _score[playerid] = TextDrawCreate(414.000000, 404.000000, "Score:~r~");
    TextDrawBackgroundColor(_score[playerid], 16711935);
    TextDrawFont(_score[playerid], 2);
    TextDrawLetterSize(_score[playerid], 0.529999, 2.599999);
    TextDrawColor(_score[playerid], 65535);
    TextDrawSetOutline(_score[playerid], 1);
    TextDrawSetProportional(_score[playerid], 1);
   
    _rank[playerid] = TextDrawCreate(414.000000, 384.000000, "Rank:~r~");
    TextDrawBackgroundColor(_rank[playerid], 16711935);
    TextDrawFont(_rank[playerid], 2);
    TextDrawLetterSize(_rank[playerid], 0.570000, 2.700000);
    TextDrawColor(_rank[playerid], 65535);
    TextDrawSetOutline(_rank[playerid], 1);
    TextDrawSetProportional(_rank[playerid], 1);
}

public OnPlayerDisconnect(playerid)
{
    TextDrawHideForPlayer(playerid, _score[playerid]);
    TextDrawHideForPlayer(playerid, _rank[playerid]);
    TextDrawDestroy(_score[playerid]);
    TextDrawDestroy(_rank[playerid]);
}

public OnPlayerSpawn(playerid)
{
    TextDrawShowForPlayer( playerid, _score[playerid]);
    TextDrawShowForPlayer( playerid, _rank[playerid]);
    return 1;
}

public OnPlayerUpdate(playerid)
{
    new string[128];
    new score = GetPlayerScore(playerid);
    format(string, sizeof(string), "Score:~r~ %d", score);
    TextDrawSetString(_score[playerid], string);
   
    if(GetPlayerScore(playerid) >= 1000) rank[playerid]     = (500, 100, "General");
    else if(GetPlayerScore(playerid) >= 700) rank[playerid] = (500, 100, "Captain");
    else if(GetPlayerScore(playerid) >= 500) rank[playerid] = (500, 100, "Lieutenant");
    else if(GetPlayerScore(playerid) >= 200) rank[playerid] = (500, 100, "Sergeant");
    else if(GetPlayerScore(playerid) >= 100) rank[playerid] = (500, 100, "Corporal");
    else if(GetPlayerScore(playerid) >= 50) rank[playerid]  = (500, 100, "Private First Class");
    else if(GetPlayerScore(playerid) >= 0) rank[playerid]   = (500, 100, "Private");
    format( string, sizeof string, "Rank:~r~ %d", rank[playerid]);
    TextDrawSetString(_rank[playerid], string);
    return 1;
}
Not sure why it compiles because wtf is this:
(500, 100, " ")

Not sure if you read it thoroughly but it is unique to the player and its not creating it 500 times as its actually being created when the player connects
worked THANK you dude you really helped me out thanks alot !