05.01.2018, 07:41
How to add a color to a safe area on a small map
if (!strcmp("/safe", cmd, true))
{
new tmp[512];
tmp = strtok(cmdtext, idx);
if(strval(tmp)<=0 || strval(tmp)>15) return Warn(playerid,"{ff0000}method: /safe [distance:1-15]");
if(IsPlayerInAnyDynamicArea(playerid)) return Warn(playerid,"{ff0000}You can not create in someone else's safe area, go somewhere to create your safe area");
new Float,Float:y,Float:z;
new ft[256];
new tt[100];
GetPlayerPos(playerid,x,y,z);
if(IsValidDynamicArea(Zone[playerid][0]))
{
DestroyDynamicArea(Zone[playerid][0]);
format(tt,sizeof(tt),"%d",Zone[playerid][1]);
dini_Unset(ZONESFILE,tt);
SAVED_ZONE[Zone[playerid][1]]=-1;
Zone[playerid][1]=-1;
Zone[playerid][0]=-1;
}
Zone[playerid][0]=CreateDynamicCircle(x,y,strval(tmp));
new d=0;
new idrd=0;
new zoneidx;
while (d==0)
{
idrd++;
if(SAVED_ZONE[idrd]!=-1) d=0;
else d=1, zoneidx=idrd;
}
format(tt,sizeof(tt),"%d",zoneidx);
Zone[playerid][1]=zoneidx;
SAVED_ZONE[zoneidx]=Zone[playerid][0];
format(ft,sizeof(ft),"%f %f %d",x,y,strval(tmp));
dini_Set(ZONESFILE,tt,ft);
new file[256];
GetPlayerName(playerid, pname, sizeof(pname));
format(file,sizeof(file),USERFILE,pname);
dini_IntSet(file,"SAFE_ZONE",zoneidx);
Inform(playerid,"You have created a safe area, please build in your security area!");
return 1;
}
if (!strcmp("/safe", cmd, true))
{
new tmp[512];
tmp = strtok(cmdtext, idx);
if(strval(tmp)<=0 || strval(tmp)>15) return Warn(playerid,"{ff0000}method: /safe [distance:1-15]");
if(IsPlayerInAnyDynamicArea(playerid)) return Warn(playerid,"{ff0000}You can not create in someone else's safe area, go somewhere to create your safe area");
new Float,Float:y,Float:z;
new ft[256];
new tt[100];
GetPlayerPos(playerid,x,y,z);
if(IsValidDynamicArea(Zone[playerid][0]))
{
DestroyDynamicArea(Zone[playerid][0]);
format(tt,sizeof(tt),"%d",Zone[playerid][1]);
dini_Unset(ZONESFILE,tt);
SAVED_ZONE[Zone[playerid][1]]=-1;
Zone[playerid][1]=-1;
Zone[playerid][0]=-1;
}
Zone[playerid][0]=CreateDynamicCircle(x,y,strval(tmp));
new d=0;
new idrd=0;
new zoneidx;
while (d==0)
{
idrd++;
if(SAVED_ZONE[idrd]!=-1) d=0;
else d=1, zoneidx=idrd;
}
format(tt,sizeof(tt),"%d",zoneidx);
Zone[playerid][1]=zoneidx;
SAVED_ZONE[zoneidx]=Zone[playerid][0];
format(ft,sizeof(ft),"%f %f %d",x,y,strval(tmp));
dini_Set(ZONESFILE,tt,ft);
new file[256];
GetPlayerName(playerid, pname, sizeof(pname));
format(file,sizeof(file),USERFILE,pname);
dini_IntSet(file,"SAFE_ZONE",zoneidx);
Inform(playerid,"You have created a safe area, please build in your security area!");
return 1;
}