Calculating ionic current / flux has been recently discussed here: Compute displace/atom & electric ionic current if you can follow that discussion, you should be able to implement the needed calculations (many issues are touched on in the thread, including comparing velocity and displacement-based approaches).
EDIT: @akohlmey and I just realised that you had simply copied his code and statements from that thread without clearly saying where you had copied it from. This is really surprising and unhelpful behavior for two reasons.
Firstly, the scientific standard requires us to always cite where we have used specific material written by other people. Even though this is an internet forum and not a scientific journal, LAMMPS is a scientific software used primarily by scientists and we would expect all LAMMPS users and forum users to adhere by the same principle.
Secondly, the LAMMPS forum is run by volunteers in our spare time; when we share our expertise (or mistakes!) to help people who have questions we are doing so with very little expectation of reward. It is the very least that users acknowledge when another user has written a script or text so that the author gets credit – our sense of wanting to help people is often the only reward we will have. In addition, it means we can straight away understand the background for your issue and know your competency level instead of making wrong assumptions. After all, I took quite some time to find the old thread and post the link, and that means I have less time now to actually think about what your issue might be and try to help you.
So in future please be very clear whenever you reuse other people’s work.