help regarding a system -
TroubleFingers - 27.03.2017
https://pastebin.com/SZREAUv4
Only the first crate works. The others don't return any messages. I've tried basically everything. Please help.
Re: help regarding a system -
Unte99 - 27.03.2017
https://sampwiki.blast.hk/wiki/Update3DTextLabelText
Read the important note.
Re: help regarding a system -
TroubleFingers - 27.03.2017
Quote:
Originally Posted by Unte99
|
Okay, it doesn't fix my script though.
Re: help regarding a system -
Unte99 - 27.03.2017
1)
pawn Код:
#define MAX_DROPPED_GPARTS 10
static GunParts[MAX_DROPPED_GPARTS][GunPart];
which is basically
pawn Код:
static GunParts[10][GunPart];
now in the command:
pawn Код:
for(new i = 0; i < sizeof(crateLocations); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 7.0, crateLocations[i][gPosx], crateLocations[i][gPosy], crateLocations[i][gPosz]))
{
you made a loop with sizeof(crateLocations), which is
pawn Код:
static crateLocations[][GunPartsCoords] = {
{2834.8857, -2386.6113, 17.5051}, // 0
{2842.3608, -2500.4163, 17.5051}, // 1
{2823.5750, -2474.1826, 12.0983}, // 2
{2837.7878, -2449.3562, 19.9220}, // 3
{2846.3259, -2447.9080, 19.9220}, // 4
{2842.2053, -2500.4648, 17.5051} // 5
};
6, because crateLocations has 6 rows of coordinates you made for picking up parts.
So the loop will be repeated only 6 times, not 10 times as the GunParts[
10] first dimension index is.
Fix this code so the loop checks all available coordinates for picking up the parts and also checks all available indexes of GunParts:
pawn Код:
CMD:takegunpart(playerid, params[])
{
/*if(pInfo[playerid][pFamily] > 0)
{
if(pInfo[playerid][pRank] >= 5)
{*/
new pickedmsg[30];
for(new i = 0; i < sizeof(crateLocations); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 7.0, crateLocations[i][gPosx], crateLocations[i][gPosy], crateLocations[i][gPosz]))
{
if(if(GunParts[i][gDropped]==0)
{
format(pickedmsg, sizeof(pickedmsg), "Skipped because GunParts[%i][gDropped]==0",i); // I added this message for debugging purposes
SendClientMessage(playerid, -1, pickedmsg);
}
if(GunParts[i][gDropped] == 0) continue;
new gunpartamount = random (6);
//PlayerInfo[playerid][Gunparts] += gunpartamount;
format(pickedmsg, sizeof(pickedmsg), "You've picked %i gun parts.", gunpartamount);
SendClientMessage(playerid, -1, pickedmsg);
GunParts[i][gDropped] = 0;
return 1;
}
}
/*}
}*/
return 1;
}
2) Don't create variables in loops.
Re: help regarding a system -
TroubleFingers - 28.03.2017
Quote:
Originally Posted by Unte99
1)
pawn Код:
#define MAX_DROPPED_GPARTS 10 static GunParts[MAX_DROPPED_GPARTS][GunPart];
which is basically
pawn Код:
static GunParts[10][GunPart];
now in the command:
pawn Код:
for(new i = 0; i < sizeof(crateLocations); i++) { if(IsPlayerInRangeOfPoint(playerid, 7.0, crateLocations[i][gPosx], crateLocations[i][gPosy], crateLocations[i][gPosz])) {
you made a loop with sizeof(crateLocations), which is
pawn Код:
static crateLocations[][GunPartsCoords] = { {2834.8857, -2386.6113, 17.5051}, // 0 {2842.3608, -2500.4163, 17.5051}, // 1 {2823.5750, -2474.1826, 12.0983}, // 2 {2837.7878, -2449.3562, 19.9220}, // 3 {2846.3259, -2447.9080, 19.9220}, // 4 {2842.2053, -2500.4648, 17.5051} // 5 };
6, because crateLocations has 6 rows of coordinates you made for picking up parts.
So the loop will be repeated only 6 times, not 10 times as the GunParts[ 10] first dimension index is.
Fix this code so the loop checks all available coordinates for picking up the parts and also checks all available indexes of GunParts:
pawn Код:
CMD:takegunpart(playerid, params[]) { /*if(pInfo[playerid][pFamily] > 0) { if(pInfo[playerid][pRank] >= 5) {*/ new pickedmsg[30]; for(new i = 0; i < sizeof(crateLocations); i++) { if(IsPlayerInRangeOfPoint(playerid, 7.0, crateLocations[i][gPosx], crateLocations[i][gPosy], crateLocations[i][gPosz])) { if(if(GunParts[i][gDropped]==0) { format(pickedmsg, sizeof(pickedmsg), "Skipped because GunParts[%i][gDropped]==0",i); // I added this message for debugging purposes SendClientMessage(playerid, -1, pickedmsg); } if(GunParts[i][gDropped] == 0) continue; new gunpartamount = random (6); //PlayerInfo[playerid][Gunparts] += gunpartamount; format(pickedmsg, sizeof(pickedmsg), "You've picked %i gun parts.", gunpartamount); SendClientMessage(playerid, -1, pickedmsg); GunParts[i][gDropped] = 0; return 1; }
} /*} }*/ return 1; }
2) Don't create variables in loops.
|
Still.
Re: help regarding a system -
Unte99 - 28.03.2017
Show your current code and tell what you changed.
Re: help regarding a system -
TroubleFingers - 28.03.2017
#include <a_samp>
#include <zcmd>
#include <sscanf2>
// 0x00FF00FF - GREEN
//
main() {}
#define MAX_DROPPED_GPARTS 6
static Text3D: takegunpart3d1;
static Text3D: takegunpart3d2;
static Text3D: takegunpart3d3;
static Text3D: takegunpart3d4;
static Text3D: takegunpart3d5;
static Text3D: takegunpart3d6;
enum GunPart {
gID,
gType,
gDropped,
Float:gPos[3]
};
enum GunPartsCoords {
Float:gPosx,
Float:gPosy,
Float:gPosz
};
CMD:here(playerid, params[])
{
SetPlayerPos(playerid, 2834.8857, -2386.6113, 17.5051);
return 1;
}
static GunParts[6][GunPart];
static crateLocations[][GunPartsCoords] = {
{2834.8857, -2386.6113, 17.5051},
{2842.3608, -2500.4163, 17.5051},
{2823.5750, -2474.1826, 12.0983},
{2837.7878, -2449.3562, 19.9220},
{2846.3259, -2447.9080, 19.9220},
{2842.2053, -2500.4648, 17.5051}
};
forward ShipArrivalTimer();
forward ShipDockingTimer();
public OnGameModeInit()
{
takegunpart3d1 = Create3DTextLabel("/takegunpart", 0x00FF00FF, 2834.8857, -2386.6113, 17.5051, 20.0, 0, 1);
takegunpart3d2 = Create3DTextLabel("/takegunpart", 0x00FF00FF, 2842.3608, -2500.4163, 17.5051, 20.0, 0, 1);
takegunpart3d3 = Create3DTextLabel("/takegunpart", 0x00FF00FF, 2823.5750, -2474.1826, 12.0983, 20.0, 0, 1);
takegunpart3d4 = Create3DTextLabel("/takegunpart", 0x00FF00FF, 2837.9119, -2449.5093, 19.9220, 20.0, 0, 1);
takegunpart3d5 = Create3DTextLabel("/takegunpart", 0x00FF00FF, 2845.8704, -2447.4880, 19.9220, 20.0, 0, 1);
takegunpart3d6 = Create3DTextLabel("/takegunpart", 0x00FF00FF, 2834.8857, -2386.6113, 17.5051, 20.0, 0, 1);
Update3DTextLabelText(takegunpart3d1, 0x00FF00FF, "");
Update3DTextLabelText(takegunpart3d2, 0x00FF00FF, "");
Update3DTextLabelText(takegunpart3d3, 0x00FF00FF, "");
Update3DTextLabelText(takegunpart3d4, 0x00FF00FF, "");
Update3DTextLabelText(takegunpart3d5, 0x00FF00FF, "");
Update3DTextLabelText(takegunpart3d6, 0x00FF00FF, "");
SetTimer("ShipArrivalTimer", 10, false);
return 1;
}
public ShipArrivalTimer()
{
SetTimer("ShipDockingTimer", 1200000, false);
for(new i = 0; i < MAX_DROPPED_GPARTS; i++)
{
new shiphasillegal = random(2);
GunParts[i][gDropped] = shiphasillegal;
if(shiphasillegal == 0) return print("No");
if(shiphasillegal == 1) return print("Yes");
}
Update3DTextLabelText(takegunpart3d1, 0x00FF00FF, "/takegunpart");
Update3DTextLabelText(takegunpart3d2, 0x00FF00FF, "/takegunpart");
Update3DTextLabelText(takegunpart3d3, 0x00FF00FF, "/takegunpart");
Update3DTextLabelText(takegunpart3d4, 0x00FF00FF, "/takegunpart");
Update3DTextLabelText(takegunpart3d5, 0x00FF00FF, "/takegunpart");
Update3DTextLabelText(takegunpart3d6, 0x00FF00FF, "/takegunpart");
return 1;
}
public ShipDockingTimer()
{
SetTimer("ShipArrivalTimer", 10800000, false);
Update3DTextLabelText(takegunpart3d1, 0x00FF00FF, "");
Update3DTextLabelText(takegunpart3d2, 0x00FF00FF, "");
Update3DTextLabelText(takegunpart3d3, 0x00FF00FF, "");
Update3DTextLabelText(takegunpart3d4, 0x00FF00FF, "");
Update3DTextLabelText(takegunpart3d5, 0x00FF00FF, "");
Update3DTextLabelText(takegunpart3d6, 0x00FF00FF, "");
return 1;
}
CMD:takegunpart(playerid, params[])
{
// if(pInfo[playerid][pFamily] > 0)
//{
//if(pInfo[playerid][pRank] >= 5)
//{
new pickedmsg[30];
for(new i = 0; i < sizeof(crateLocations); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 7.0, crateLocations[i][gPosx], crateLocations[i][gPosy], crateLocations[i][gPosz]))
{
if(GunParts[i][gDropped] == 0) continue;
new gunpartamount = random (6);
//PlayerInfo[playerid][Gunparts] += gunpartamount;
format(pickedmsg, sizeof(pickedmsg), "You've picked %i gun parts.", gunpartamount);
SendClientMessage(playerid, -1, pickedmsg);
GunParts[i][gDropped] = 0;
}
return 1;
}
//}
//}
return 1;
}
Re: help regarding a system -
Unte99 - 28.03.2017
So what exactly did you change?
Re: help regarding a system -
TroubleFingers - 28.03.2017
Quote:
Originally Posted by Unte99
So what exactly did you change?
|
Everything you said
Re: help regarding a system -
Unte99 - 28.03.2017
Quote:
Originally Posted by TroubleFingers
Everything you said
|
You didn't even use the command I pasted for you and told you what to do to fix it and you are saying that you changed everything when you didn't do shit. If you are just waiting for someone to paste the working code for you, you are in the wrong section. This is "Scripting Help", not "I paste the code and you fix it for me". Come back to this section when you have the minimum knowledge of sa-mp scripting. When you think you have the knowledge, try x2 times more of the time you spent acquiring the knowledge and then you can come here asking for help. You have no idea what the hell the current code does, what are you even doing here?