Health bar-like textdraw and /eat
#1

Hey guys. I'm working on a RP server and I've done some pretty interesting things but I want to change the hunger meter from number to a textdraw like the HP bar. I saw some tutorials but I don't really understand. Can someone show me an example? Thank you. Also I want a to make a command like /eat [fruit/soda/meat] so I don't have to create thousand commands for thousand different meals or something like /use [Whatever object you have in INV]
Reply
#2

Read the SA-MP wiki on TextDrawCreate and to develop your scripting, not for scripting requests. Attempt them yourself and if all else fails, post what you've attempted and help will be an option. If you're not sure how to go about any of this, use http://forum.sa-mp.com/search.php?do=process
Reply
#3

The textdraw I'll do more reseaches ... couldn't be that hard. But I don't really understand how to do the /use [whatever] command. I'm not requesting for someone else to do my script. I just want to see a example so I could follow and create my own scripts.

-Off topic [Rep - Reason "NIGGER" for requesting a bit of help? Dude, go home.] + I tried alot but everything ended up with errors or bugs.
Reply
#4

For the /eat thing, you need to use sscanf to see what he will put after /eat [text].
You will need to check if he has what ever he put after /eat, let's say you used: /eat soda:
Check if he has soda in his inventory depending on your script, if he doesn't, you send him an error message, else you will put his hunger meter lower.

To use sscanf, you need to use something like this:
pawn Код:
new meal[32];
if(sscanf(params, "s[32]", meal)) return SendClientMessage(playerid, -1, "USAGE: /eat [soda/shit/whatever");
if(strcmp(params, "shit", true) == 0)
{
/*if doesnt have shit in his inv
SendClientMessage(playerid, -1, "You don't have shit in your inventory"); */


SetPlayerHealth(playerid, GetPlayerHealth(playerid) +30); // for example
}
Hope you get the idea.
Reply
#5

For the '/use [food type]'; you can use strcmp inside a CMD. https://sampwiki.blast.hk/wiki/Strcmp

This is an example of it using ZCMD.
pawn Код:
CMD:use(playerid, params[])
{
    new type[10];
    if(sscanf(params, "s[10]", type)) { SCM(playerid, COLOR_HERE, "USAGE: /use [type]"); return SCM(playerid, COLOR_HERE, "TYPES: fruit | soda | meat"); }
    if(IsPlayerInRangeOfPoint(playerid, radius, x,y,z)) //where the player has to be close too.
    {
         if(!strcmp(type, "fruit", false, sizeof(type))
         {
              //code here for when you type '/use fruit'
         }
        else if(!strcmp(type, "soda", false, sizeof(type))
         {
              //code here for when you type '/use soda'
         }
    }
    return 1;
}
Reply
#6

Thank you guys. I've done something like this
pawn Код:
YCMD:mananca(playerid, params[], help)
{
    new meal[32];
    if (help) return SendClientMessage(playerid, 0x808080FF, "/mananca este folosit pentru a manca consumabilele din inventar");
    if(sscanf(params, "s[32]", meal)) return SendClientMessage(playerid, -1, "Folosire: /mananca [suc/mancare]");
    if(strcmp(params, "mancare", true) == 0)
    {
    if(!PlayerInfo[playerid][pFood]) return SendClientMessage(playerid, -1, "Nu ai mancare");
    PlayerInfo[playerid][pFood] --;
    PlayerInfo[playerid][pHunger] += 30;
    }
    return 1;
}
The code is working just fine. But that was just a test now I'll finish the real script. Thank you again for your help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)