SA-MP Forums Archive
Set enum from string - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Set enum from string (/showthread.php?tid=208946)



Set enum from string - Mike Garber - 09.01.2011

Well what I'd like to do is set an enum value from a string;

Example
pawn Код:
format(string, 8, "something");
CarSystem[i][some] = string;
But It gives me;

error 006: must be assigned to an array
Assigned to an array? What does that mean?

(Never worked with It before)


Re: Set enum from string - Joe Staff - 09.01.2011

You have to use format directlyon tge enum

Format(CarSystem[i][some],64,"%s",cheese);


Re: Set enum from string - Mike Garber - 09.01.2011

Thank you, that worked.


Re: Set enum from string - Calgon - 09.01.2011

Use strcat(), it's a much more efficient method in comparison to format() for copying strings.


Re: Set enum from string - Mike Garber - 09.01.2011

Quote:
Originally Posted by Calgon
Посмотреть сообщение
Use strcat(), it's a much more efficient method in comparison to format() for copying strings.
Thank you, but It's only going to be done upon starting the server.


Re: Set enum from string - Cameltoe - 09.01.2011

Quote:
Originally Posted by Mike Garber
Посмотреть сообщение
Thank you, but It's only going to be done upon starting the server.
strmid also does the same : ))


Re: Set enum from string - Calgon - 09.01.2011

Remember it for the future, personally I'd change the code, mainly because it's just one single line that makes a moderate difference.

Quote:
Originally Posted by Cameltoe
Посмотреть сообщение
strmid also does the same : ))
strmid is used to extract characters from a string, not to just copy single strings.