25.12.2015, 07:58
Guys i have a gift script for my server but i got some problem in it whenever i get gift sometimes it repeat the location and it happen alot of times spawning on same location if you take one here is my code and tell me how to fix to spawn at every new and random location
This is timer of Gift
This is pickup code of gift
This is timer of Gift
PHP код:
forward GiftLoc();
public GiftLoc()
{
if(gifttime <= 0)
{
new gifttmp2[10], giftstring[170], giftstring2[170], gifttmp3[10], Float:gx, Float:gy, Float:gz, GiftModels;
if(!CreatedGift)
{
if(ongift == 1)
{
giftloc = random(dini_Int(AddDirFile(dir_datafiles, FILE_TOTALSTAT), "giftlocs"));
format(gifttmp2, 10, "gloc%d", giftloc);
//giftloc2 = giftloc;
if(dini_Exists(AddDirFile(dir_glocationfiles, gifttmp2)))
{
GiftModels = dini_Int(AddDirFile(dir_glocationfiles, gifttmp2), "GModel");
gx = dini_Int(AddDirFile(dir_glocationfiles, gifttmp2), "LocationX");
gy = dini_Int(AddDirFile(dir_glocationfiles, gifttmp2), "LocationY");
gz = dini_Int(AddDirFile(dir_glocationfiles, gifttmp2), "LocationZ");
GiftPickup = CreatePickup(GiftModels, 1, gx, gy, gz, -1);
format(giftstring, sizeof(giftstring), "{FF0000}Santa Claus: {FFFFFF}There is a present for you in %s. Merry Christmas, HO HO HO!", dini_Get(AddDirFile(dir_datafiles, FILE_GLOCSS), gifttmp2));
SendClientMessageToAll2(COLOR_RED, giftstring);
CreatedGift = 1;
}
}
}
else
{
format(gifttmp3, 10, "gloc%d", giftloc);
if(CreatedGift == 1)
{
format(giftstring2, sizeof(giftstring2), "{FF0000}Santa Claus: {FFFFFF}My present is still waiting for you in %s. Merry Christmas, HO HO HO!", dini_Get(AddDirFile(dir_datafiles, FILE_GLOCSS), gifttmp3));
SendClientMessageToAll2(COLOR_RED, giftstring2);
}
}
gifttime = GetGiftInfo("Gifttime");
}
else if(gifttime > GetGiftInfo("Gifttime")) gifttime=0;
else gifttime--;
}
PHP код:
new giftstring[120], gifttmp3[7], Float:gx, Float:gy, Float:gz, GiftModels;
giftloc = random(dini_Int(AddDirFile(dir_datafiles, FILE_TOTALSTAT), "giftlocs"));
format(gifttmp3, 10, "gloc%d", giftloc);
//giftloc2 = giftloc;
if(CreatedGift == 0)
{
if(dini_Exists(AddDirFile(dir_glocationfiles, gifttmp2)))
{
GiftModels = dini_Int(AddDirFile(dir_glocationfiles, gifttmp3), "GModel");
gx = dini_Int(AddDirFile(dir_glocationfiles, gifttmp3), "LocationX");
gy = dini_Int(AddDirFile(dir_glocationfiles, gifttmp3), "LocationY");
gz = dini_Int(AddDirFile(dir_glocationfiles, gifttmp3), "LocationZ");
GiftPickup = CreatePickup(GiftModels, 1, gx, gy, gz, -1);
format(giftstring, sizeof(giftstring), "{FF0000}Santa Claus: {FFFFFF}The next present is located in %s. HO HO HO!", dini_Get(AddDirFile(dir_datafiles, FILE_GLOCSS), gifttmp3));
SendClientMessageToAll2(COLOR_RED, giftstring);
CreatedGift = 1;
}
}
}