Small problem - 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)
+--- Thread: Small problem (
/showthread.php?tid=598491)
Small problem -
Squirrel - 13.01.2016
Okay so this loop doesnt work properly, im trying to get weapon from ground but it doesnt do it
PHP код:
for(new i = 0; i < sizeof(GunInfo); i++) {
if(IsPlayerInRangeOfPoint(playerid,5.0,GunInfo[i][GunX],GunInfo[i][GunY],GunInfo[i][GunZ])) {
if(GetPlayerVirtualWorld(playerid) == GunInfo[i][GunWorld]) {
DestroyDynamicObject(GunObject[i]);
GunInfo[i][GunX] = 2000.00;
GunInfo[i][GunY] = 2000.00;
GunInfo[i][GunZ] = 3000.00;
GunInfo[i][GunWorld] = 666;
GivePlayerWeapon(playerid,GunInfo[i][GunWeaponID],GunInfo[i][GunWeaponAmmo]);
GunInfo[i][GunX] = 2000.00;
}
}
}
PHP код:
enum Ddata {
GunWeaponID,
GunWeaponAmmo,
Float:GunX,
Float:GunY,
Float:GunZ,
GunWorld,
GunInterior
};
new GunInfo[MAX_GUNDROP][Ddata],
GunObject[MAX_GUNDROP];
Re: Small problem -
LetsOWN[PL] - 13.01.2016
pawn Код:
for(new GunId = 0; GunId < MAX_GUNDROP; GunId++) {
if( IsPlayerInRangeOfPoint( playerid, 5.0, GunInfo[GunId][GunX], GunInfo[GunId][GunY], GunInfo[GunId][GunZ]) &&
GetPlayerVirtualWorld(playerid) == GunInfo[GunId][GunWorld])
{
GunInfo[GunId][GunX] = 2000.0;
GunInfo[GunId][GunY] = 2000.0;
GunInfo[GunId][GunZ] = 3000.0;
GunInfo[GunId][GunWorld] = 666;
GivePlayerWeapon(playerid, GunInfo[GunId][GunWeaponID], GunInfo[GunId][GunWeaponAmmo]);
// Consider reseting GunWeaponID and GunWeaponAmmo
//in here. But maybe it is not necessary.
break;
}
}
Re: Small problem -
Squirrel - 13.01.2016
Nope still doesnt help
This is how I drop it
PHP код:
DropPlayerGun(playerid,weaponid,ammo,Float:X,Float:Y,Float:Z,World,tmpInt) {
for(new GunId = 0; GunId < MAX_GUNDROP; GunId++) {
if(GunInfo[GunId][GunX] == 0.0 && GunInfo[GunId][GunY] == 0.0 && GunInfo[GunId][GunZ] == 0.0) {
GunInfo[GunId][GunWeaponID] = weaponid;
GunInfo[GunId][GunWeaponAmmo] = ammo;
GunInfo[GunId][GunX] = X;
GunInfo[GunId][GunX] = Y;
GunInfo[GunId][GunX] = Z;
GunInfo[GunId][GunWorld] = World;
GunInfo[GunId][GunInterior] = tmpInt;
GunObject[GunId] = CreateDynamicObject(GetGunObjectID(weaponid),X,Y,Z-1, 90.0000, -90.0000, 90.0000, World, tmpInt = -1, -1,200.0);
return true;
}
}
return true;
}
And this is how I pick it up
PHP код:
for(new GunId = 0; GunId < MAX_GUNDROP; GunId++) {
if(IsPlayerInRangeOfPoint(playerid,5.0,GunInfo[GunId][GunX],GunInfo[GunId][GunY],GunInfo[GunId][GunZ])) {
if(GetPlayerVirtualWorld(playerid) == GunInfo[GunId][GunWorld]) {
GivePlayerWeapon(playerid,GunInfo[GunId][GunWeaponID],GunInfo[GunId][GunWeaponAmmo]);
DestroyDynamicObject(GunObject[GunId]);
GunInfo[GunId][GunX] = 2000.00;
GunInfo[GunId][GunY] = 2000.00;
GunInfo[GunId][GunZ] = 3000.00;
GunInfo[GunId][GunWorld] = 666;
GunInfo[GunId][GunX] = 2000.00;
}
}
}
Re: Small problem -
-CaRRoT - 13.01.2016
Please add this line at the end of the loop
Код:
printf("gun picked");
and lemme know if it prints or not, cause I cant see the problem with the loop itself.
Re: Small problem -
Squirrel - 13.01.2016
Nope doesnt get to call that one, its like it doesnt get the location correctly.
EDIT: problem fixed, I found a way to do it hehe, I just looped thru the object ID itself. Aka I got dynamic object pos of GunObject and then compared it to my pos