Problem with function - 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 function (
/showthread.php?tid=215409)
Problem with function -
woaha - 23.01.2011
When Loading stock get called; it only creates 1 object and unloading function doesn't work at all. Why?
Enum
pawn Код:
#define MAX_SUIHKUOBJ 33 // File contains 32 lines
enum krsuihku
{
model,
Float:kroX,
Float:kroY,
Float:kroZ,
Float:kroRX,
Float:kroRY,
Float:kroRZ
};
new korjaamosuihku[MAX_SUIHKUOBJ][krsuihku];
Loading stock
pawn Код:
new SplitDiv[7][MAX_SUIHKUOBJ];
new filestring[256];
new File: file = fopen(SUIHKU_FILE, io_read);
if (file)
{
for(new krsid = 0; krsid < MAX_SUIHKUOBJ; krsid++)
{
fread(file, filestring);
split(filestring, SplitDiv, ',');
korjaamosuihku[krsid][model] = strval(SplitDiv[0]);
korjaamosuihku[krsid][kroX] = floatstr(SplitDiv[1]);
korjaamosuihku[krsid][kroY] = floatstr(SplitDiv[2]);
korjaamosuihku[krsid][kroZ] = floatstr(SplitDiv[3]);
korjaamosuihku[krsid][kroRX] = floatstr(SplitDiv[4]);
korjaamosuihku[krsid][kroRY] = floatstr(SplitDiv[5]);
korjaamosuihku[krsid][kroRZ] = floatstr(SplitDiv[6]);
krsid = CreateDynamicObject(korjaamosuihku[krsid][model], korjaamosuihku[krsid][kroX], korjaamosuihku[krsid][kroY], korjaamosuihku[krsid][kroZ], korjaamosuihku[krsid][kroRX], korjaamosuihku[krsid][kroRY], korjaamosuihku[krsid][kroRZ]);
}
}
fclose(file);
issuihkuon = 1;
Unloading stock
pawn Код:
stock UnloadKorjaamoSuihku()
{
for(new krsid = 0; krsid < MAX_SUIHKUOBJ; krsid++)
{
DestroyDynamicObject(krsid);
}
issuihkuon = 0;
}
Calling
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 2, 450.1813,-1850.3495,5.4607))
{
if(issuihkuon == 0)
{
LoadKorjaamoSuihku();
}
if(issuihkuon == 1)
{
UnloadKorjaamoSuihku();
}
}
Re: Problem with function -
woaha - 24.01.2011
bumb
Re: Problem with function -
woaha - 25.01.2011
bumb
Re: Problem with function -
Jefff - 25.01.2011
You must add into array
pawn Код:
korjaamosuihku[krsid][Loaded] = CreateDynamicObject(...
and then
pawn Код:
stock UnloadKorjaamoSuihku()
{
for(new krsid = 0; krsid < MAX_SUIHKUOBJ; krsid++)
{
if(korjaamosuihku[krsid][Loaded] != 0) {
DestroyDynamicObject(krsid);
korjaamosuihku[krsid][Loaded]=0;
}
}
issuihkuon = 0;
}