Filterscript not using server side money? [Help]
#1

Here is something from the filterscript i am using where I have added the line

Added code:
Код:
PlayerInfo[i][pCash] -= cost;
Filterscript code:
Код:
if(RefuelTime[i] > 0 && GetPVarInt(i, "FuelStation"))
			{
				new vehicleid = GetPlayerVehicleID(i);
				Fuel[vehicleid] += 2.0;
				RefuelTime[i]--;
				if(RefuelTime[i] == 0)
				{
					if(Fuel[vehicleid] >= 100.0) Fuel[vehicleid] = 100.0;
					new stationid = GetPVarInt(i, "FuelStation");
					new cost = floatround(Fuel[vehicleid]-GetPVarFloat(i, "Fuel"))*FUEL_PRICE;
					if(GetPlayerState(i) != PLAYER_STATE_DRIVER || Fuel[vehicleid] >= 100.0 || GetPlayerMoney(i) < cost
					|| !IsPlayerInRangeOfPoint(i, 10.0, FuelStationPos[stationid][0], FuelStationPos[stationid][1], FuelStationPos[stationid][2]))
					{
						if(GetPlayerMoney(i) < cost) cost = GetPlayerMoney(i);
						PlayerInfo[i][pCash] -= cost;
						format(string, sizeof(string), "~r~-$%d", cost);
						GameTextForPlayer(i, string, 2000, 3);
						format(string, sizeof(string), "You pay $%d for fuel", cost);
						SendClientMessage(i, COLOR_WHITE, string);
						SetPVarInt(i, "FuelStation", 0);
						SetPVarFloat(i, "Fuel", 0.0);
					}
					else
					{
						RefuelTime[i] = 5;
						format(string, sizeof(string), "~w~refueling...~n~~r~-$%d", cost);
						GameTextForPlayer(i, string, 2000, 3);
					}
				}
			}
Here's what I get..
Код:
C:\Documents and Settings\Phil\Desktop\DFRP Server\filterscripts\avs.pwn(1079) : error 017: undefined symbol "PlayerInfo"
C:\Documents and Settings\Phil\Desktop\DFRP Server\filterscripts\avs.pwn(1079) : warning 215: expression has no effect
C:\Documents and Settings\Phil\Desktop\DFRP Server\filterscripts\avs.pwn(1079) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\Phil\Desktop\DFRP Server\filterscripts\avs.pwn(1079) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Phil\Desktop\DFRP Server\filterscripts\avs.pwn(1079) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
What steps do I need to take in order for the FS to use my server side money?

What do you need to see in order to help me?
Reply
#2

You have an enum that works with the variable PlayerInfo in your game-mode, right?

Well, unfortunately, the FS doesn't read data from the GM. You can't use PlayerInfo unless it's defined in the script you're working with.

You could use PVar's to allow the FS to read data from the GM. Otherwise, put the code from the FS into your GM.
Reply
#3

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
You have an enum that works with the variable PlayerInfo in your game-mode, right?

Well, unfortunately, the FS doesn't read data from the GM. You can't use PlayerInfo unless it's defined in the script you're working with.

You could use PVar's to allow the FS to read data from the GM. Otherwise, put the code from the FS into your GM.
And I take it to define PlayerInfo in the FS would take a whole lot more effort than putting the FS into the GM right? What would you suggest is the quickest way?

EDIT: I tried putting all the enum and bits from the GM into the FS.. This just made the FS compile fine but the money just stuck the same IG when buying/selling from the FS.

EDIT 2: If I put the code from my FS into my GM won't this break the FS when saving/loading is concerned??
Reply
#4

The quickest way would be to make PlayerInfo[i][pCash] -= cost; a PVar in both the GM, and the FS.

SetPVarInt(), GetPVarInt()

The BEST way, put the FS into the GM. I generally run my modes w/o any FS's alongside them.
Reply
#5

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
The quickest way would be to make PlayerInfo[i][pCash] -= cost; a PVar in both the GM, and the FS.

SetPVarInt(), GetPVarInt()

The BEST way, put the FS into the GM. I generally run my modes w/o any FS's alongside them.
I edited my post above ^^

Just curious to see an example of how I can use this in my case?

Код:
SetPVarInt(), GetPVarInt()
Reply
#6

Basically, doing this:

pawn Код:
SetPVarInt(playerid, "Money", 100);
... is the same as doing this:

pawn Код:
PlayerInfo[playerid][pMoney] = 100;
So, you would basically need to change every line like this:

pawn Код:
PlayerInfo[playerid][pMoney]++;
to this:

pawn Код:
SetPVarInt(playerid, "Money", GetPVarInt(playerid, "Money")++);
So, your code...

pawn Код:
PlayerInfo[i][pCash] -= cost;
Could easily become:

pawn Код:
SetPVarInt(playerid, "Money", GetPVarInt(playerid, "Money") - cost);
NOTE: The variable names you use in PVars (i.e. "Money") are case sensitive. So, MONEY, is not equal to Money. I would recommend to make everything a CAPITAL variable, just to be on the safe side.
Reply
#7

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
Basically, doing this:

pawn Код:
SetPVarInt(playerid, "Money", 100);
... is the same as doing this:

pawn Код:
PlayerInfo[playerid][pMoney] = 100;
So, you would basically need to change every line like this:

pawn Код:
PlayerInfo[playerid][pMoney]++;
to this:

pawn Код:
SetPVarInt(playerid, "Money", GetPVarInt(playerid, "Money")++);
So, your code...

pawn Код:
PlayerInfo[i][pCash] -= cost;
Could easily become:

pawn Код:
SetPVarInt(playerid, "Money", GetPVarInt(playerid, "Money") - cost);
NOTE: The variable names you use in PVars (i.e. "Money") are case sensitive. So, MONEY, is not equal to Money. I would recommend to make everything a CAPITAL variable, just to be on the safe side.
Brilliant mate! I've been scripting for a little while now but when I don't understand something or don't know something I come to a brickwall sometimes as to WHAT I need to know exactly. You just told me EXACTLY what I need to know and that made perfect sense! I'll give this ago mate thanks alot! I don't know loads but I'm a quick learner! =]

EDIT: You should update the wiki as this made better sense lol..

EDIT after adding your code:

Ignore what I just put (Edited because I wrote incorrectly and found where I went wrong)

Thanks for the code man I'll see if this works!
Reply
#8

Honestly, the SA:MP wiki is much more help than a lot of the people here on the forums. If you know a fair amount of code already, most of the examples it gives you will make complete sense; it's just a matter of following everything.

While I would LOVE to be able to write a tutorial on some of the PAWN basics, I just don't have the time.
Reply
#9

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
Honestly, the SA:MP wiki is much more help than a lot of the people here on the forums. If you know a fair amount of code already, most of the examples it gives you will make complete sense; it's just a matter of following everything.

While I would LOVE to be able to write a tutorial on some of the PAWN basics, I just don't have the time.
Hi mate I added the code to every line and it compiled with no errors or anything but now IG when I buy/sell anything (which is part of the FS) it doesn't take any money away or give any money. What am I missing here? :/ Should I just move it into the GM lol?

EDIT: Ok I'm gonna go for it! Is there a simple way to move the FS into the GM like dividing them in 2 but working as 1? That would be nice! LOL! I take it your gonna say I've gotta put all the bits in all the correct places
Reply
#10

You cannot repeat callbacks. So, if the FS has things under OnPlayerConnect, all of that needs to be placed under the OnPlayerConnect callback in the game-mode.

That goes for all callbacks.

Remember to take everything from OnFilterScriptInit and OnFilterScriptExit and put them in the proper OnGameMode* callbacks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)