Weapon saving
#1

if (strcmp("/pg", cmdtext, true, 10) == 0)
{
new ammo, gun;
GetPlayerWeaponData(playerid,0,gun,ammo);
PlayerInfo[playerid][pGun] == gun;
PlayerInfo[playerid][pGunAmmo] == ammo;
}

I get 2 warnings saying "Invalid expression assumed 0" or somthin
I want it to set the pGun and pgunAmmo to whatever he has in his hands , then onplayerupdate this will be updated so when he relogs he will have the gun and ammo back help pl0x.
Reply
#2

Quote:
pawn Код:
if (strcmp("/pg", cmdtext, true, 10) == 0)
  {
   new ammo, gun;
   GetPlayerWeaponData(playerid,0,gun,ammo);
   PlayerInfo[playerid][pGun] == gun;
   PlayerInfo[playerid][pGunAmmo] == ammo;
  }
Those lines below are useless, and cause your warning.

Quote:

PlayerInfo[playerid][pGun] == gun;
PlayerInfo[playerid][pGunAmmo] == ammo;

If you use == it can be used only on if conditions.
So you should use =, not ==.


pawn Код:
PlayerInfo[playerid][pGun] = gun;
PlayerInfo[playerid][pGunAmmo] = ammo;

Reply
#3

you have to save it for each weapon slot. slot 0 can be brass knuckles or unarmed.
so do it like this:
Код:
new ammo, gun;
GetPlayerWeaponData(playerid,0,gun,ammo);
PlayerInfo[playerid][pGun0] = gun;
PlayerInfo[playerid][pGunAmmo0] = ammo;
GetPlayerWeaponData(playerid,1,gun,ammo);
PlayerInfo[playerid][pGun1] = gun;
PlayerInfo[playerid][pGunAmmo1] = ammo;
etc. till slot 12(max.)
This way it saves all weapons
Reply
#4

Quote:
Originally Posted by Notime
you have to save it for each weapon slot. slot 0 can be brass knuckles or unarmed.
so do it like this:
Код:
/* code */
etc. till slot 12(max.)
This way it saves all weapons
Your code will only store the last slot to the gun and ammo variables + your way is very inefficient.
Reply
#5

Quote:
Originally Posted by Don Correlli
Quote:
Originally Posted by Notime
you have to save it for each weapon slot. slot 0 can be brass knuckles or unarmed.
so do it like this:
Код:
/* code */
etc. till slot 12(max.)
This way it saves all weapons
Your code will only store the last slot to the gun and ammo variables + your way is very inefficient.
Could please tell me how to do it properly?
Reply
#6

Guys, I am not that much of a programmer. but I am a huge GTA SA fan. Can someone explain me a code to save the Machine Gun ( now it is near the ranch : I don't remeber the name of the ranch right now, it is other side of the San Francisco bridge, I think). I

All I need it to always appear near CJ's first house. because, I have gang wars
I've already found a way to get the unlimited ammo for it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)