Creating a new function
#1

Hey, I'm trying to create a weed system so when you /smokeweed it gets your health and adds +25hp. I haven't made a way to get weed (e.g growing it) so I've made a command for admins to give you it so I can test it out. Everything seems to be working well so far but I'm having troubles trying to get the amount of weed the player has.

E.g if the admin gave the player 3 grams, you can use /smokeweed 3 times, then it will say "You don't have any weed left!". I'm pretty sure I've done the /agiveweed correct (I'm concerned about the "amount" but pretty sure it's correct) and all I want now is for the /smokeweed command to get the amount of weed the player has (or was given by the admin) and continue from there. I've tried to create a "GetPlayerWeed" function so it can see how much weed the player has, but not sure how it will take -1 gram from the player once they use /smokeweed. Please help me out.

Thanks in advanced, here's the script.

pawn Код:
CMD:agiveweed(playerid, params[])
{
    new targetid, string[128], amount;
    if(PlayerStat[playerid] [AdminLevel] < 2) return SendClientMessage(playerid, GREY, "You don't have access to this command!");
    if(sscanf(params, "ud[128]", targetid, amount)) return SendClientMessage(playerid, GREY, "USAGE: /agiveweed [playerid] [amount]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, GREY, "That player is not connected!");
    {
        Weed[targetid] = amount;
        format(string, sizeof(string), "You have given %s weed!", GetOOCName(targetid));
        SendClientMessage(playerid, WHITE, string);
        format(string, sizeof(string), "Administrator %s has given you weed!", GetOOCName(playerid));
        SendClientMessage(targetid, WHITE, string);
        AdminActionLog(string);
    }
    return 1;
}
   
GetPlayerWeed(playerid, amount)
{
    new amount;
    if(Weed[playerid] = amount;         // need to fix
    return amount
}

CMD:smokeweed(playerid, params[])
{
    new string[128], amount;
    if(Weed [playerid] == 0) return SendClientMessage(playerid, WHITE, "You do not have any weed seeds!");
    if(Weed [playerid] == 1)
    {
        ApplyAnimation(playerid, "JST_BUISNESS", "smoke_01", 4.1, 1, 1, 1, 0, 1, 1);
        new Float:health;
        GetPlayerHealth(playerid, health);
        //if(health > 60) return SendClientMessage(playerid, WHITE, "You cannot smoke weed if your health is 60 or above!");
        SetPlayerHealth(playerid, health+25);
        GetPlayerWeed(playerid, amount);
        format(string, sizeof(string), "%s takes out a joint and smokes some weed.", GetOOCName(playerid));
        SendNearByMessage(playerid, ACTION_COLOR, string, 4);
    }
    return 1;
}
Already done
pawn Код:
new Weed[MAX_PLAYERS];
// and

Weed[playerid] = 0;

These are the errors I need to fix because either the function or the command is wrong

pawn Код:
C:\Users\cbrickell\Desktop\PWN\gamemodes\EGRP.pwn(414) : warning 219: local variable "amount" shadows a variable at a preceding level
C:\Users\cbrickell\Desktop\PWN\gamemodes\EGRP.pwn(415) : warning 211: possibly unintended assignment
C:\Users\cbrickell\Desktop\PWN\gamemodes\EGRP.pwn(415) : error 001: expected token: ")", but found ";"
C:\Users\cbrickell\Desktop\PWN\gamemodes\EGRP.pwn(415) : error 036: empty statement
C:\Users\cbrickell\Desktop\PWN\gamemodes\EGRP.pwn(417) : error 001: expected token: ";", but found "}"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.
Thanks!
Reply


Messages In This Thread
Creating a new function - by Josh_Main - 29.09.2014, 14:57
Re: Creating a new function - by MasonSFW - 29.09.2014, 15:05
Re: Creating a new function - by Josh_Main - 29.09.2014, 15:12
Re: Creating a new function - by Stinged - 29.09.2014, 15:21
Re: Creating a new function - by Josh_Main - 29.09.2014, 15:25
Re: Creating a new function - by awsomedude - 29.09.2014, 15:27
Re: Creating a new function - by Stinged - 29.09.2014, 15:31
Re: Creating a new function - by Josh_Main - 29.09.2014, 16:26
Re: Creating a new function - by DavidBilla - 29.09.2014, 18:15

Forum Jump:


Users browsing this thread: 2 Guest(s)