PlayerTextDrawSetString -
DTV - 04.10.2016
I've ran into a problem where I can't specify the player textdraw I want to update with a formatted string.
pawn Код:
public AssignInventoryNameValues(playerid)
{
for(new i=0; i<MAX_INVSLOTS; i++)
{
new txt[32],string[128];
switch(IsStackableItemInPlayerSlot(playerid,i))
{
case 0: format(string,sizeof(string),"%i. %s",i+1,GetItemName(playerid,i));
case 1: format(string,sizeof(string),"%i. %s (%i)",i+1,GetItemName(playerid,i),Player[playerid][pInventoryAmount][i]);
}
format(txt,sizeof(txt),"InvSlot%i[playerid]",i+1);
PlayerTextDrawSetString(playerid,txt,string); //this is the error line
}
return 1;
}
When I compile all I get for the error is:
pawn Код:
error 035: argument type mismatch (argument 2)
Re: PlayerTextDrawSetString -
StrikerZ - 04.10.2016
According to this
https://sampwiki.blast.hk/wiki/PlayerTextDrawSetString the
Код:
PlayerTextDrawSetString(playerid,txt,string);
"txt" need to replaced with the textdraw and yeah i think the format line
Код:
format(txt,sizeof(txt),"InvSlot%i[playerid]",i+1);
the "txt" should be replaced with "string". Try it i'm not sure about this.
Re: PlayerTextDrawSetString -
vassilis - 04.10.2016
Quote:
Originally Posted by DTV
I've ran into a problem where I can't specify the player textdraw I want to update with a formatted string.
pawn Код:
public AssignInventoryNameValues(playerid) { for(new i=0; i<MAX_INVSLOTS; i++) { new txt[32],string[128]; switch(IsStackableItemInPlayerSlot(playerid,i)) { case 0: format(string,sizeof(string),"%i. %s",i+1,GetItemName(playerid,i)); case 1: format(string,sizeof(string),"%i. %s (%i)",i+1,GetItemName(playerid,i),Player[playerid][pInventoryAmount][i]); } format(txt,sizeof(txt),"InvSlot%i[playerid]",i+1); PlayerTextDrawSetString(playerid,txt,string); //this is the error line } return 1; }
When I compile all I get for the error is:
pawn Код:
error 035: argument type mismatch (argument 2)
|
It's because PlayerTextDrawSetString must have 3 parameters. playerid, textname, textdrawstring.
Is the second parameter a textdraw variable?
Re: PlayerTextDrawSetString -
StrikerZ - 04.10.2016
Quote:
Originally Posted by vassilis
It's because PlayerTextDrawSetString must have 3 parameters. playerid, textname, textdrawstring.
Is the second parameter a textdraw variable?
|
See he just made it like this new txt[32] which easily prooves that it isn't textdraw. That's what i'm saying that change it into a textdraw.
Re: PlayerTextDrawSetString -
DTV - 04.10.2016
Sorry for not clarifying, I do have the textdraw variables towards the top of the script:
pawn Код:
// ---Player Textdraws---
new PlayerText:InvBox[MAX_PLAYERS],PlayerText:InvAmount[MAX_PLAYERS],PlayerText:InvSlot1[MAX_PLAYERS],PlayerText:InvSlot2[MAX_PLAYERS],PlayerText:InvSlot3[MAX_PLAYERS];
//other textdraw variables
Re: PlayerTextDrawSetString -
StrikerZ - 04.10.2016
Код:
format(string,sizeof(string),"InvSlot%i[playerid]",i+1);
PlayerTextDrawSetString(playerid,InvBox,string);
Try it and tell me
Re: PlayerTextDrawSetString -
DTV - 04.10.2016
Quote:
Originally Posted by Sunehildeep
Код:
format(string,sizeof(string),"InvSlot%i[playerid]",i+1);
PlayerTextDrawSetString(playerid,InvBox,string);
Try it and tell me
|
That won't work. If you look at the code, you can see that the string is already being formatted for something else, so it can't be used and thus why I have the txt string there.
Re: PlayerTextDrawSetString -
StrikerZ - 04.10.2016
Didn't saw that. Try this.
Код:
format(txt,sizeof(txt),"InvSlot%i[playerid]",i+1);
PlayerTextDrawSetString(playerid,InvBox,string); // InvBox is the textdraw being used here. The second value in this line must be always a textdraw or it will return with argument error
Re: PlayerTextDrawSetString -
DTV - 04.10.2016
Quote:
Originally Posted by Sunehildeep
Didn't saw that. Try this.
Код:
format(txt,sizeof(txt),"InvSlot%i[playerid]",i+1);
PlayerTextDrawSetString(playerid,InvBox,string); // InvBox is the textdraw being used here. The second value in this line must be always a textdraw or it will return with argument error
|
I still don't see how this would work at all, the txt string isn't being used in this example so it's useless, not to mention InvBox would just show up as being an invalid variable.
Re: PlayerTextDrawSetString -
SickAttack - 04.10.2016
You're doing it wrong, use one array and instead of InvSlot%d, it will be InvSlot[%d]. You can't use a variable that stores a string, as an integer with the wrong tag.
Re: PlayerTextDrawSetString -
DTV - 04.10.2016
Quote:
Originally Posted by SickAttack
You're doing it wrong, use one array and instead of InvSlot%d, it will be InvSlot[%d]. You can't use a variable that stores a string, as an integer with the wrong tag.
|
So instead of having it like PlayerText:InvSlot1[playerid],PlayerText:InvSlot2[playerid] (so on and so forth), you mean have it like PlayerText:InvSlot[x] (x being the number)?
Re: PlayerTextDrawSetString -
SickAttack - 04.10.2016
InvSlot[playerid][x]
Re: PlayerTextDrawSetString -
DTV - 04.10.2016
Oh alright, I'll try that and get back to you with the results.
Re: PlayerTextDrawSetString -
DTV - 04.10.2016
Hmm, it still has the same error.
EDIT: Nevermind, I still tried formatting when I realized I didn't need to, thanks for the help