SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 25/02/2015, 09:35 PM   #1
Alvin007
Huge Clucker
 
Alvin007's Avatar
 
Join Date: Mar 2011
Location: Tunisia
Posts: 245
Reputation: 9
Default 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)) 
__________________
Alvin007 is offline   Reply With Quote
Old 25/02/2015, 09:41 PM   #2
DanishHaq
High-roller
 
Join Date: Sep 2011
Location: Manchester, England, United Kingdom
Posts: 1,352
Reputation: 134
Default 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.
__________________
SA-MP Scripting knowledge: 80%
Pawn scripting knowledge: 3%

Know the difference...
DanishHaq is offline   Reply With Quote
Old 25/02/2015, 09:52 PM   #3
Alvin007
Huge Clucker
 
Alvin007's Avatar
 
Join Date: Mar 2011
Location: Tunisia
Posts: 245
Reputation: 9
Default Re : small problem - formating

Works fine, but i'd like to know what's wrong with format.
I mean in my case.
__________________
Alvin007 is offline   Reply With Quote
Old 25/02/2015, 09:58 PM   #4
DanishHaq
High-roller
 
Join Date: Sep 2011
Location: Manchester, England, United Kingdom
Posts: 1,352
Reputation: 134
Default 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.
__________________
SA-MP Scripting knowledge: 80%
Pawn scripting knowledge: 3%

Know the difference...
DanishHaq is offline   Reply With Quote
Old 25/02/2015, 10:08 PM   #5
Alvin007
Huge Clucker
 
Alvin007's Avatar
 
Join Date: Mar 2011
Location: Tunisia
Posts: 245
Reputation: 9
Default Re : small problem - formating

Ok understood! i got it now, thanks alot
__________________
Alvin007 is offline   Reply With Quote
Old 25/02/2015, 11:21 PM   #6
Alvin007
Huge Clucker
 
Alvin007's Avatar
 
Join Date: Mar 2011
Location: Tunisia
Posts: 245
Reputation: 9
Default 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.
__________________
Alvin007 is offline   Reply With Quote
Old 26/02/2015, 06:22 AM   #7
CalvinC
High-roller
 
CalvinC's Avatar
 
Join Date: Nov 2014
Location: Denmark
Posts: 1,831
Reputation: 114
Default 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.
__________________
[Tutorial] Custom Playerdamage system
Desert Eagle's dealing too much damage, you want one-hit sniper kills, or damage based on body parts? Check this out.
CalvinC is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formating ShoortyFl Scripting Help 3 21/10/2014 09:48 AM
Formating Pawn Problem... burnfire Scripting Help 6 24/06/2013 09:13 AM
Text formating problem rAzvAn18 Scripting Help 4 11/05/2013 04:31 PM
Formating a message? A7X_CEEJAY Scripting Help 2 18/06/2012 04:42 PM


All times are GMT. The time now is 04:18 PM.


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