Help with some very basics things
#1

first

how do i use a var on a message like

new var[6] = blah

and then send a message with

"this is a test message var"

then on the player screen to appear

"this is a test message blah"

second

how do i use a command to set a var like /money [playerid] [amount]

GivePlayerMoney(playerid,amount)

something like that
Reply
#2

You have to format the string to set it to a variable like this:

pawn Код:
format(var,sizeof(var),"%s",SettingData);
// Then format string and add var to it and send client message

new string[120];
format(string,sizeof(string),"This is a test message %s",var);
SendClientMessage(playerid,0xFFFFFFFF,string);
Here is an example of the /money command in ZCMD + SSCANF.
pawn Код:
CMD:money(playeird,params[])
{
    new pID,amount; // variables that we'll use later in the cmd.
    if(sscanf(params,"ud",pID,amount)) return SendClientMessage(playerid,0xFFFFFFFF,"USAGE: /money [playerid] [amount]"); // Checks if player hasn't typed the right syntax of the command.
    if(GetPlayerMoney(playerid) < amount) return SendClientMessage(playerid,0xCCCCCCFF,"You don't have enough money."); // If player has less money than he put in amount, don't execulte further.
    GivePlayerMoney(pID,amount); // Give money to the other player.
    GivePlayerMoney(playeird,-amount); // Take away the amount that player gave to the other player.
    return 1;
}
Reply
#3

so putting [] on a cmd like /money [par1] [par2] and if i set a var with par1 then the system will set with the parameters that i write on the cmd ??

like cmd is /test [value]

and if i set a var with value when i write for example /test blah
the system will set the var with blah ?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)