problem with enum and arrays - 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: problem with enum and arrays (
/showthread.php?tid=244134)
problem with enum and arrays -
bijoyekuza - 26.03.2011
hey sciprters
I got this variable
enum pInfo{
pUnit[32],
}
new PlayerInfo[MAX_PLAYERS][pInfo];
I got this command
Код:
dcmd_unitset(playerid, params[])
{
new id,unit[32];
if(!sscanf(params,"us[32]",id,unit))
{
if(PlayerInfo[playerid][pCop] > 5)
{
PlayerInfo[id][pUnit] = unit;
new pName[MAX_PLAYER_NAME],victim[MAX_PLAYER_NAME];
GetPlayerName(id,victim,sizeof(victim));
GetPlayerName(playerid,pName,sizeof(pName));
new string[256];
format(string,sizeof(string),"%s has set your unit name to %s",pName,unit);
SendClientMessage(id,COLOR_ADMINS,string);
format(string,sizeof(string),"You have set %s's unit name to %s.",victim,unit);
SendClientMessage(playerid,COLOR_ADMINS,string);
}else return SendClientMessage(playerid,COLOR_AFOR,"Your rank doesnt allow you to use this tool !");
}else return SendClientMessage(playerid,COLOR_RED,"Usage : /unitset [PLAYERID][UNITNAME]");
return 1;
}
so that makes the player unit anything he wants . and it is working fine .
but when I quit the game I want to save the player's unit name in dini .
So I tried to do this
dini_Set(file,"pUnit",PlayerInfo[playerid][pUnit] = "tiger2");
and it says
error 047: array sizes do not match, or destination array is too small
Re: problem with enum and arrays -
Jochemd - 26.03.2011
Yeah, use format and not = "tiger2"
Re: problem with enum and arrays -
bijoyekuza - 26.03.2011
you mean like
new string[32];
format(string,sizeof(string),"%s",X);
I dont get it
what to do
Re: problem with enum and arrays -
Jochemd - 26.03.2011
pawn Код:
new string[30];
format(string,sizeof string,"tiger2");
dini_Set(file,"pUnit",string);