String help
#1

Kinda new to this
PHP код:
FacInfo[pInfo[playerid][pFaction]][fLeader] = PlayerName(playerid); 
FacInfo[MAX_FACTIONS][fLeader] is a string
Reply
#2

You have to use Format
https://sampwiki.blast.hk/wiki/Format
PHP код:
format(FacInfo[pInfo[playerid][pFaction]][fLeader], sizeof(FacInfo[pInfo[playerid][pFaction]][fLeader]), PlayerName(playerid)); 
Reply
#3

You should use strcat instead of format as it's slower, define this in your script;
PHP код:
#if !defined strcpy
   #define strcpy(%0,%1) strcat((%0[0] = EOS, %0), %1)
#endif 
then use
PHP код:
strcpy(FacInfo[pInfo[playerid][pFaction]][fLeader], PlayerName(playerid)); 
Cred: https://sampforum.blast.hk/showthread.php?tid=608087
Reply
#4

Added both. I don't know why but it says that strcpy is an undefined symbol. Error line is here

PHP код:
strcpy(FacInfo[pInfo[playerid][pFaction]][fLeader], PlayerName(playerid)); 
Reply
#5

PHP код:
#define overwrite(%0,%1) strcat((%0[0] = EOS, %0), %1)

CMD:makemeleader(playerid) {
  
overwrite(FacInfo[pInfo[playerid][pFaction]][fLeader], PlayerName(playerid));  
  return 
1;

Reply
#6

Tried using format
PHP код:
(7477) : error 001expected token"]"but found "-identifier-"
(7477) : warning 215expression has no effect
(7477) : error 001expected token";"but found "]"
(7477) : error 029invalid expressionassumed zero
(7477) : fatal error 107too many error messages on one line

7477     format
(FacInfo[pInfo[playerid][pFaction]][fLeader], sizeof(FacInfo[pInfo[playerid][pFaction]][fLeader]), PlayerName(playerid)); 
Reply
#7

Experimented something. Worked fine

PHP код:
new leadername[MAX_PLAYER_NAME];
leadername PlayerName(playerid);
strcpy(FacInfo[pInfo[playerid][pFaction]][fLeader], leadernameMAX_PLAYER_NAME); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)