String help - 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)
+--- Thread: String help (
/showthread.php?tid=624959)
String help -
NealPeteros - 25.12.2016
Kinda new to this
PHP код:
FacInfo[pInfo[playerid][pFaction]][fLeader] = PlayerName(playerid);
FacInfo[MAX_FACTIONS][fLeader] is a string
Re: String help -
Amads - 25.12.2016
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));
Re: String help -
Luicy. - 25.12.2016
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
Re: String help -
NealPeteros - 26.12.2016
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));
Re: String help -
Luicy. - 26.12.2016
PHP код:
#define overwrite(%0,%1) strcat((%0[0] = EOS, %0), %1)
CMD:makemeleader(playerid) {
overwrite(FacInfo[pInfo[playerid][pFaction]][fLeader], PlayerName(playerid));
return 1;
}
Re: String help -
NealPeteros - 26.12.2016
Tried using format
PHP код:
(7477) : error 001: expected token: "]", but found "-identifier-"
(7477) : warning 215: expression has no effect
(7477) : error 001: expected token: ";", but found "]"
(7477) : error 029: invalid expression, assumed zero
(7477) : fatal error 107: too many error messages on one line
7477 format(FacInfo[pInfo[playerid][pFaction]][fLeader], sizeof(FacInfo[pInfo[playerid][pFaction]][fLeader]), PlayerName(playerid));
Re: String help -
NealPeteros - 26.12.2016
Experimented something. Worked fine
PHP код:
new leadername[MAX_PLAYER_NAME];
leadername = PlayerName(playerid);
strcpy(FacInfo[pInfo[playerid][pFaction]][fLeader], leadername, MAX_PLAYER_NAME);