Weapon saving - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Weapon saving (
/showthread.php?tid=122303)
Weapon saving -
(Jeff) - 21.01.2010
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.
Re: Weapon saving - lameguy - 21.01.2010
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;
Re: Weapon saving -
notime - 21.01.2010
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
Re: Weapon saving -
Correlli - 21.01.2010
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:
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.
Re: Weapon saving -
(Jeff) - 21.01.2010
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:
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?
Re: Weapon saving -
ravi80k - 23.01.2010
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