New Function error
#1

I tried to make a new function that allows you to create a pickup with attached 3d text.

PHP код:
stock CreatePickupWith3DText(modeltypeFloat:XFloat:YFloat:ZVirtualworldtext[], color)
{
    
CreatePickup(modeltypeFloat:XFloat:YFloat:ZVirtualworld);
    
Create3DTextLabel(text[], colorFloat:XFloat:YFloat:Z+0.750Virtualworld1);
    return 
1;

But i get this error : C:\Users\TOSHIBA\Desktop\Project Work\gamemodes\TWC2.pwn(890) : error 029: invalid expression, assumed zero ( the Create3DTextLabel line)
any help?
Reply
#2

pawn Код:
Create3DTextLabel(text[], color, Float:X, Float:Y, Float:Z+0.75, 0, Virtualworld, 1);
Should be
pawn Код:
Create3DTextLabel(text, color, Float:X, Float:Y, Float:Z+0.75, 0, Virtualworld, 1);
Reply
#3

Thanks ! Rep+
But why there shouldnt be [] ?
EDIT : The text doesnt show!
savedisk = CreatePickupWith3DText(1277, 2, 2510.1780,133.8019,26.8837, -1, "Game Save", 0xB40100FF);

This didnt show the text :/ help?
Reply
#4

text[] is indicator that function accepts arrays (and in turn, strings) - it is placed in function definition. When you are calling that function, you have to pass specific variable, not indicator - and therefore "text" without square brackets is enough.
Reply
#5

Quote:
Originally Posted by Misiur
Посмотреть сообщение
text[] is indicator that function accepts arrays (and in turn, strings) - it is placed in function definition. When you are calling that function, you have to pass specific variable, not indicator - and therefore "text" without square brackets is enough.
Ah i understand now, thanks, but can you take a look at it again? it doesnt work
Reply
#6

Oh, sorry, I only saw your second question. You have to remove all Float:Variable before stuff in function calls, so instead:
pawn Код:
CreatePickup(model, type, Float:X, Float:Y, Float:Z, Virtualworld);
Create3DTextLabel(text, color, Float:X, Float:Y, Float:Z+0.75, 0, Virtualworld, 1);
it has to be
pawn Код:
CreatePickup(model, type, X, Y, Z, Virtualworld);
Create3DTextLabel(text, color, X, Y, Z+0.75, 0, Virtualworld, 1);
Reason is identical as with text - Float is indicator of variable type while declaring it, or accepting as an argument.
Reply
#7

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Oh, sorry, I only saw your second question. You have to remove all Float:Variable before stuff in function calls, so instead:
pawn Код:
CreatePickup(model, type, Float:X, Float:Y, Float:Z, Virtualworld);
Create3DTextLabel(text, color, Float:X, Float:Y, Float:Z+0.75, 0, Virtualworld, 1);
it has to be
pawn Код:
CreatePickup(model, type, X, Y, Z, Virtualworld);
Create3DTextLabel(text, color, X, Y, Z+0.75, 0, Virtualworld, 1);
Reason is identical as with text - Float is indicator of variable type while declaring it, or accepting as an argument.
Thanks now i can understand everything!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)