SA-MP Forums Archive
Saving bullet positions? - 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: Saving bullet positions? (/showthread.php?tid=504402)



Saving bullet positions? - Dokins - 04.04.2014

How can I save bullet positions? Not to any file or mysql or anything, but I mean in just a variable temporarily and then delete them all after with a command?

I know it's with this:
https://sampwiki.blast.hk/wiki/OnPlayerWeaponShot

But I just want to create a label on top of the bullet location, How can I save it temporarily?


Re: Saving bullet positions? - SickAttack - 04.04.2014

You ask for to much help... Go learn to do stuff on your own. And plus this is so simple to do, you don't even bother to read the wiki witch tells you what you need to know, its just case of reading it. Even if someone helps you, you just say thanks, like as the helpers are your slaves, I suggest you learn on your own and you will succeed.

fX The X coordinate that the shot hit.
fY The Y coordinate that the shot hit.
fZ The Z coordinate that the shot hit.

New Float:BulletX[MAX_PLAYERS];
New Float:BulletY[MAX_PLAYERS];
New Float:BulletZ[MAX_PLAYERS];

BulletX[playerid] = fX;
BulletY[playerid] = fY;
BulletZ[playerid] = fZ;


Re: Saving bullet positions? - Dokins - 04.04.2014

'You ask for too much help' - That may be the most ridiculous statement I've ever heard. I have only been scripting 9 months, I'm only aware of how to load it from MySQL as that's where I usually get ID's from. I think you'll find I PM the people who have helped me after, saying a personal thank you and I in-fact made this post just last week: https://sampforum.blast.hk/showthread.php?tid=501737 Thanking a player.

I am an amateur scripter, I don't pretend to know what I don't and I certainly do not bring judgement to other people I do not know.

I appreciate that, but that will over-write the CO-ORDS.

I need to save EACH bullets location, That's the issue I don't know how to do, like. When you CreateVehicle the vehicleid = CreateVehicle,

What is the bullet created? Do I have to do MAX_BULLETS


Re: Saving bullet positions? - SickAttack - 04.04.2014

"That may be the most ridiculous statement I've ever heard" - http://forum.sa-mp.com/search.php?searchid=7985244 tells you everything. "Scripting 9 months" You been here more time than i have and you call yourself an "amateur scripter"? Really?

You cannot save one and each bullet location. If you use a Tec9 then shoot a lot of objects, and save it to the variable you'll create lag. Imagine how many cells you need to do this.


Re: Saving bullet positions? - LocMax - 04.04.2014

Quit bothering, so what if he asks for help? at least he's mature and doesn't beg for reputation on every corner.

OnTopic:
Do you want an actual bullet object appear on ground and label it or just a label anywhere the bullet hits?

In case you want to label bullet anywhere it gets stuck at,
We have this function:
pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
The Float:fX, Float:fY, Float:fZ are location of where the bullet hits.
With that being said, I think you should just create a 3D Label every time OnPlayerWeaponShot is called.

pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    Create3DTextLabel("Bullet shell", 0xFF0000FF, fX, fY, fZ, 20.0, 0, 0);
    return 1;
}



Re: Saving bullet positions? - Dokins - 04.04.2014

That link showed me nothing. I created the account LONG before I actually began scripting, infact someone gave me this account.

I do call myself an amateur scripter simply because time has no meaning towards your level of ability. None at all. Know why? Cos everyone in the world has different learning abilities. You don't know me, You don't know if I am mentally challenged, you don't know if I have any issues in personal life, you don't know if I have suffered brain trauma. You base all of your opinions on forum posts upon a person you have never met or even know the age, gender, sex or anything. Once I post something, when I understand it, I learn it. I know how to do the majority of things in scripting, scratch that, a lot - all I need to and if I don't know I ask. Then I learn.

NO-ONE IS OBLIGED TO REPLY TO ANY POSTS ON THE FORUMS, REGARDLESS OF SECTION.

“Never look down on anybody unless you're helping them up.”

@LocMax

Thanks for that.

I'm just looking for the location to be saved, the co-ords. I plan to add a text label saying 'BULLET' to each one, I'm just not entirely sure as of how to save EVERY fired bullet's location?


Re: Saving bullet positions? - Patrick - 04.04.2014

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
"That may be the most ridiculous statement I've ever heard" - http://forum.sa-mp.com/search.php?searchid=7985244 tells you everything. "Scripting 9 months" You been here more time than i have and you call yourself an "amateur scripter"? Really? Use your head boy.
Uhm Excuse me? He's asking for help so don't be fucking rude, How about if he joined SA-MP forums for fun in 2010 and no intention of learning PAWN, and he started to learn PAWN at 2012 or late 2013, if you think he always ask question then don't reply and shut up instead.

@Dokins - Here's an example, hope you will learn something from it, this will store the weapon used, hittype, hitid and all the offsets where the bullet went.

pawn Код:
enum WeaponData {
    e_weapon,
    e_hittype,
    e_hitid,
    Float:bOffSet[ 3 ]
}
new wData[ MAX_PLAYERS ][ WeaponData];

public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    new string[144];

    weaponid = wData[ playerid ][ e_weapon ];
    hittype = wData[ playerid ][ e_hittype ];
    hitid = wData[ playerid ][ e_hitid ];
    fX = wData[ playerid ][ bOffSet ][ 0 ];
    fY = wData[ playerid ][ bOffSet ][ 1 ];
    fZ = wData[ playerid ][ bOffSet ][ 2 ];

    format(string, sizeof(string), "[DEBUG - Original] Weapon %i fired. hittype: %i   hitid: %i   pos: %f, %f, %f", weaponid, hittype, hitid, fX, fY, fZ);
    SendClientMessage(playerid, -1, string);
    format(string, sizeof(string), "[DEBUG - Stored] Weapon %i fired. hittype: %i   hitid: %i   pos: %f, %f, %f", wData[ playerid ][ e_weapon ],
    wData[ playerid ][ e_hittype ], wData[ playerid ][ e_hitid ], wData[ playerid ][ bOffSet ][ 0 ], wData[ playerid ][ bOffSet ][ 1 ], wData[ playerid ][ bOffSet ][ 2 ]);
    SendClientMessage(playerid, -1, string);
    return 1;
}



Re: Saving bullet positions? - Dokins - 04.04.2014

Thank you, Patrick, I really appreciate the comment + time it took to add that.

I understand that, but won't each bullet over-write the last one? Saving only one location in the end?

EDIT: @LocMax

I just seen your edit, AHH I see! It's actually more simple than I thought, but how do I delete the labels/locations?


Re: Saving bullet positions? - Patrick - 04.04.2014

Quote:
Originally Posted by Dokins
Посмотреть сообщение
Thank you, Patrick, I really appreciate the comment + time it took to add that.

I understand that, but won't each bullet over-write the last one? Saving only one location in the end?
Yes it will override the last stored integers & floats every time the OnPlayerWeaponShot is called.


Re: Saving bullet positions? - LocMax - 04.04.2014

Quote:
Originally Posted by Dokins
Посмотреть сообщение
Thank you, Patrick, I really appreciate the comment + time it took to add that.

I understand that, but won't each bullet over-write the last one? Saving only one location in the end?
"I'm just looking for the location to be saved, the co-ords. I plan to add a text label saying 'BULLET' to each one"
Create3DTextLabel every time OnPlayerWeaponShot is called, if weapon is one with bullets (not RPG, flame thrower, teargas) that should make a label at every bullet I guess.

EDIT: To delete it, you'd need to make a new variable:
pawn Код:
new Text3D:BLabel;
But you'd need to add something like MAX_BULLETS to it, the bullets should have their ID, I think it can be done with a define of MAX_BULLETS or a variable BulletID, but I'm not sure how to do it so I won't post wrong info.