Posts: 8
Threads: 3
Joined: Mar 2011
You using a string with no size...
ie:
pawn Код:
new reason;
if(sscanf(params, "s", reason))
Try:
pawn Код:
new reason[128];
if(sscanf(params, "s[128]", reason))
Posts: 8
Threads: 3
Joined: Mar 2011
Quote:
Originally Posted by Medal Of Honor team
I have fix the error by replacing this
pawn Код:
new busid,cost,payout,name[128]; if(sscanf(params,"iiis",busid,cost,payout,name))
To This
pawn Код:
if(sscanf(params,"iiis[128]",busid,cost,payout,name))
|
Yes thats what i said
NOTE: if you have two strings the same size
ie.
pawn Код:
new busid,cost,payout,name[128],string[128];
just make one [150] so you can define the size in sccanf and it wont trip out(IDK if it does but i do it)
Like:
pawn Код:
new busid,cost,payout,name[150],string[128];
if(sscanf(params,"iiis[150]",busid,cost,payout,name))
Posts: 8
Threads: 3
Joined: Mar 2011
Quote:
Originally Posted by Medal Of Honor team
thanks for your help
|
No problem mate
Posts: 1,506
Threads: 69
Joined: Feb 2008
Quote:
Originally Posted by Magazinez
Yes thats what i said
NOTE: if you have two strings the same size
ie.
pawn Код:
new busid,cost,payout,name[128],string[128];
just make one [150] so you can define the size in sccanf and it wont trip out(IDK if it does but i do it)
Like:
pawn Код:
new busid,cost,payout,name[150],string[128];
if(sscanf(params,"iiis[150]",busid,cost,payout,name))
|
It wont trip out, you can make it
pawn Код:
new string[64],string2[64],string3[64],string4[64],string5[64],string6[64],level,cash;
if(!sscanf(params,"s[64]s[64]s[64]s[64]s[64]s[64]ii",string1,string2,string3,string4,string5,string6,level,cash))
Also remember, sscanf returns FALSE when it DOES finds the parameters, just like strcmp returns false when two strings match.
Posts: 1,506
Threads: 69
Joined: Feb 2008
Quote:
Originally Posted by Magazinez
I thought i did when it doesnt??
How does this work?
doesnt ! mean "if" is not?
so the correct way would be:
pawn Код:
if(sscanf(params, "i", id)) return SendClientMessage(playerid,0x0, "USAGE: /command [id]");
Well IDK this is how it works for me..
|
Yes your code is correct. It all depends what style you wanna code it with.
pawn Код:
if(!sscanf(params, "i", id))
{
// Code
return 1;
}
else return SendClientMessage(playerid,-1,"USAGE: /command [id]");
Works aswell.