[HELP] Simple question.
#1

Sup guys.
I have a problem in my script, i want to make that the armour builds up.
For example when you use an item you get 5 armour, next time to you ues it you get another 5.
5+5=10 easy right? but all you can do is to set a constant variable like

pawn Код:
SetPlayerArmour(playerid, 5);
Next time he going to use it, it will stay on 5....
How can i make something like this to work:

pawn Код:
SetPlayerArmour(playerid, +5);
Thanks!
Reply
#2

Well you are taking it in a wrong way. You have to define a variable and get the player's armour and add 5 to do that, like this.

pawn Код:
new Float:Armour;//define a floating variable with a name Armour.
GetPlayerArmour(playerid,Armour);//Store the value of player's armour in this variable using GetPlayerArmour function.
SetPlayerArmour(playerid,Armour + 5);// You need to add current Armour + 5 to do your task in SetPlayerArmour function.
Reply
#3

pawn Код:
C:\Users\Xsyiaris\Documents\VPS\Penitentiary Roleplay\gamemodes\PRP.pwn(4264) : warning 219: local variable "Armour" shadows a variable at a preceding level
C:\Users\Xsyiaris\Documents\VPS\Penitentiary Roleplay\gamemodes\PRP.pwn(4265) : error 035: argument type mismatch (argument 2)
C:\Users\Xsyiaris\Documents\VPS\Penitentiary Roleplay\gamemodes\PRP.pwn(4266) : warning 213: tag mismatch
C:\Users\Xsyiaris\Documents\VPS\Penitentiary Roleplay\gamemodes\PRP.pwn(4266) : warning 213: tag mismatch
C:\Users\Xsyiaris\Documents\VPS\Penitentiary Roleplay\gamemodes\PRP.pwn(4264) : warning 203: symbol is never used: "Armour"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase
Errors....

The code:

pawn Код:
new string[64]; //Line 4263
            new Float:Armour; //Line 4264
            GetPlayerArmour(playerid,Armour); //Line 4265
            SetPlayerArmour(playerid,Armour + 5); //Line 4266
            format(string, sizeof(string), "* %s takes out a lighter and a joint and smokes it", GetICName(playerid)); //Line 4267
            SendNearByMessage(playerid, ACTION_COLOR, string, 10); //Line 4268
            SetPlayerDrunkLevel (playerid, 4500); //Line 4269
            SetTimer("CurrentlyHigh", 180000, false); //Line 4270
            PlayerStat[playerid][Joint]--; //Line 4271
Reply
#4

I guess it's declared as global without the Float tag. Change the name:

pawn Код:
new
    Float: fArmour
;
GetPlayerArmour( playerid, fArmour );
SetPlayerArmour( playerid, fArmour + 5 );
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
I guess it's declared as global without the Float tag. Change the name:

pawn Код:
new
    Float: fArmour
;
GetPlayerArmour( playerid, fArmour );
SetPlayerArmour( playerid, fArmour + 5 );
Works, thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)