PDA

View Full Version : Help with variable


,TomY'
25/06/2018, 11:03 AM
Hi all. Have problem with code. I have this:
stock CreateFraction(FractionName[], Float:EnterX, Float:EnterY, Float:EnterZ, id, lvl, skini, uzdyrba,galininka[],spalv[],koma[], virtualus =0)
{
new fquery[100];
format(workInfo[workid][nam], 100, "%s", FractionName);
format(workInfo[workid][spalva], 7, "%s", spalv);
format(workInfo[workid][galininkas], 100, "%s", galininka);
format(workInfo[workid][komanda], 20, "%s", koma);
workInfo[workid][jobid] = id;
workInfo[workid][skinid] = skini;
workInfo[workid][lvlneed] = lvl;
workInfo[workid][uzdirba] = uzdyrba;
workInfo[workid][checkpointidx] = CreatePickupA(1275 ,2, EnterX, EnterY, EnterZ,virtualus);
format(fquery,sizeof(fquery),"SELECT * FROM `darbai` WHERE `id` = '%i'",id);
mysql_function_query(MysqlConnection,fquery,true,"DarbuLoad","d",workid);
workid ++;
return 1;
}

And then after server start
CreateFraction("FracName", 237.2637,110.7220,8000.2188, 0, 20000, 0,0,"test","E55B3C","/test");

This code working good. But now I trying to this:
CreateFraction("%i", 237.2637,110.7220,8000.2188, 0, 20000, 0,0,"test","E55B3C","/test",myname);
And I getting error: argument type mismatch. Is it possible, to use FractionName from variable, like I trying to do?

div
25/06/2018, 11:17 AM
format a string buddy


new mystring[24];
format(mystring, sizeof(mystring, "%i", myname); //If it's a string, it should be %s though
CreateFraction(mystring, 237.2637,110.7220,8000.2188, 0, 20000, 0,0,"test","E55B3C","/test");


This should work..


EDITTED: Had a mistake, try again now..

,TomY'
25/06/2018, 12:20 PM
Using this code - no errors, but code doesn't work. Text does not appear :/

Verc
25/06/2018, 12:38 PM
Read the comment,it should be %s if it's a name.

div
25/06/2018, 01:02 PM
Dayum, please rep if it helped, I'm in desperate need of reputation to advertise the server I will be HAVING in future :/


Btw how much rep do i need to post in the ADVERTISEMENT SUBFORUM?

,TomY'
25/06/2018, 03:00 PM
I using %s, not %i and still no text... :(

div
25/06/2018, 03:04 PM
If you want the fraction to be created with your name like ",TomY"


new mystring[24], myname[24];
GetPlayerName(playerid, myname, 24);
format(mystring, sizeof(mystring, "%s", myname); //If it's a string, it should be %s though
CreateFraction(mystring, 237.2637,110.7220,8000.2188, 0, 20000, 0,0,"test","E55B3C","/test");

[/CODE]

GTLS
25/06/2018, 05:13 PM
Dayum, please rep if it helped, I'm in desperate need of reputation to advertise the server I will be HAVING in future :/


Btw how much rep do i need to post in the ADVERTISEMENT SUBFORUM?

begging does not get you true rep lol. You need 15 rep for advertisement. Dont beg for rep and have some self respect. If people wanna give you rep, they will if dont, then its not a big deal. rep isnt money. rep is rep on SAMP forums which is useless in rest of the world.

,TomY'
26/06/2018, 06:54 AM
Still need help. This code does not working for me.. Pickup appears, but text - no.

Verc
26/06/2018, 07:16 AM
Post the function of CreatePickupA.
Or you should create pickup like normal using CreatePickup or CreateDynamicPickup.

JasonRiggs
26/06/2018, 07:31 AM
What do you want??

If you're trying to do something like Create a pickup and a text upon it, You can just CreatePickup or CreateDynamicPickup for the ICON itself, Then go ahead using Create3DTextLabel or CreateDynamic3DTextLabel to create the text itself, but as I can see, You didn't even create a text so it will show..

,TomY'
26/06/2018, 07:33 AM
I say, that when I use this code:

new mystring[24];
format(mystring, sizeof(mystring), "%s", myname);
CreateFraction(mystring, 237.2637,110.7220,8000.2188, 0, 20000, 0,0,"test","E55B3C","/test");

I cant get myname, server doesnt shows mystring text.

When I use this:
CreateFraction("FracName", 237.2637,110.7220,8000.2188, 0, 20000, 0,0,"test","E55B3C","/test");

It works correctly, I see FracName text in server.

JasonRiggs
26/06/2018, 07:38 AM
Because myname in here is defined as a variable not as a text..

You must do something like this.. new myname[24]; That's for example tho, If you're creating this fraction with a command then use params.. Like that it might appear, but you didn't even insert any value of string inside this variable "myname" that's why nothing shows..