SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   small problem - formating (https://forum.sa-mp.com/showthread.php?t=565187)

Alvin007 25/02/2015 09:35 PM

small problem - formating
 
This is the Line 701 that shows errors.
PHP Code:

format(FactionInfo[id][fName],sizeof(FactionInfo[id][fName]),fname); 

I tried also:
PHP Code:

format(FactionInfo[id][fName],sizeof(FactionInfo[id][fName]),"%s",fname); 

but same error message.

Quote:

C:\Users\moka\Desktop\PROG\03z\gamemodes\test.pwn( 701) : error 001: expected token: "]", but found "-identifier-"
C:\Users\moka\Desktop\PROG\03z\gamemodes\test.pwn( 701) : warning 215: expression has no effect
C:\Users\moka\Desktop\PROG\03z\gamemodes\test.pwn( 701) : error 001: expected token: ";", but found "]"
C:\Users\moka\Desktop\PROG\03z\gamemodes\test.pwn( 701) : error 029: invalid expression, assumed zero
C:\Users\moka\Desktop\PROG\03z\gamemodes\test.pwn( 701) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.

Knowing that fname is going to be inserted.

PHP Code:

new txt,fname[28], typevworldFloat:XiFloat:YiFloat:Ziinti;
    if(
sscanf(params"s[28]ddfffd"fnametypeintiXiYiZitxt)) 


DanishHaq 25/02/2015 09:41 PM

Re: small problem - formating
 
pawn Code:
// if I was you I'd use strmid instead of format like this
strmid(FactionInfo[id][fName], fname, 0, strlen(fname));

If this doesn't work it'd be useful to see everything around line 701 too to identify the problem a bit more.

Alvin007 25/02/2015 09:52 PM

Re : small problem - formating
 
Works fine, but i'd like to know what's wrong with format.
I mean in my case.

DanishHaq 25/02/2015 09:58 PM

Re: small problem - formating
 
I don't know exactly, but what I do know is that strmid would be used for storing things in variables with enumerators (XInfo[var][var]) etc. and format is used for putting text together, for example "Admin Alvin007 has said hello to you", you'd need to format this because it has a variable that needs to be put in.

As I said because I don't know exactly the wording is a little noobish, I think someone else will be able to help you with a more lengthy statement. Or just check out the SA-MP wiki, general wikis etc., I'm sure you'll find your answer there.

Alvin007 25/02/2015 10:08 PM

Re : small problem - formating
 
Ok understood! i got it now, thanks alot :)

Alvin007 25/02/2015 11:21 PM

Re : small problem - formating
 
OUPS!
careful, it is strmid(FactionInfo[id][fName], fname, 0, strlen(fname),29); instead, you forgot about the last parameter which is the destination's length.

CalvinC 26/02/2015 06:22 AM

Re: small problem - formating
 
It will work if you use your string size instead of using sizeof.
Hence why i showed you an example that didn't use sizeof.


All times are GMT. The time now is 05:30 PM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.