Scripting Help
#1

Hey I Wrote a Script and I want to know if itґs ok.

if (strcmp("/heal", cmdtext, true, 10) == 0)
{
if(GetPlayerMoney(playerid) < 10000)
{
SendClientMessage(playerid, 0xAA3333AA, "You donґt have enough money!");
return 1;
}
if(GetPlayerHealth(playerid) == 100)
{
SendClientMessage(playerid, 0xAA3333AA, "Your Health Is 100!");
GivePlayerMoney(playerid,0);
SetPlayerHealth(playerid,100);
return 1;
}


if(GetPlayerMoney(playerid) > 10000)
if(GetPlayerHealth(playerid) == 100)
{
GivePlayerMoney(playerid,-10000);
SetPlayerHealth(playerid,100);
return 1;
}
}
Reply
#2

Here you go
Код:
CMD:heal(playerid, params[])
{
    if(GetPlayerMoney(playerid) < 10000) return SendClientMessage(playerid, COLOR_RED, "<!>You need atleast 10000$ in order to heal!");
	GivePlayerMoney(playerid, -10000); //taking 10k from them
	SetPlayerHeatlh(playerid, 100); //Setting HP
	return 1;
}
Replace CMD:Heal with
Код:
if(!strcmp(cmdtext, "/heal", true, 4))
If you are using Strcmp
Reply
#3

Thanks But thats 1st part. I need when you have 100% life to send me a message and say that I have 100% life but that doesnt take any money if you have 100%.
Reply
#4

Here you go

PHP код:
if(!strcmp(cmdtext"/heal"true4))
{
    new 
Float:health;
    
GetPlayerHealth(playerid,health);
    if (
health 100.0//If they have less than 100.00 hp. If the 100.0 is smaller than Health
    
{
        if(
GetPlayerMoney(playerid) < 10000) return SendClientMessage(playeridCOLOR_RED"<!>You need atleast 10000$ in order to heal!");
        
GivePlayerMoney(playerid, -10000); //taking 10k from them
        
SetPlayerHealth(playerid100); //Setting HP
        
return 1;
    }
    else
    {
        
SendClientMessage(playeridCOLOR_RED"<!>You already have 100 life!");
    }
    return 
1;

Reply
#5

Thanks Man it works!!
Reply
#6

O and Can any one tell me how to set a money timer so each player can get 5000$ every 15 minutes (SA-MP minutes)??
Reply
#7

under public OnGameModeInit() put this
pawn Код:
SetTimerEx("GivePlayerMoney", 54000, false, "i", playerid);
and at the end of your script add

pawn Код:
forward GivePlayerMoney(playerid);
public GivePlayerMoney(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        GivePlayerMoney(i, 5000);
    }
    return 1;
}
Reply
#8

I get this:
error 017: undefined symbol "playerid"
error 021: symbol already defined: "GivePlayerMoney"
error 021: symbol already defined: "GivePlayerMoney"
error 010: invalid function or declaration
error 010: invalid function or declaration
Reply
#9

Код:
forward MoneyGiven(playerid);
public MoneyGiven(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        GivePlayerMoney(i, 5000);
    }
    return 1;
}

SetTimerEx("MoneyGiven", 54000, false, "i", playerid);
GivePLayerMoney is SAMP sided.

Also I'd suggest you to use foreach

Код:
public MoneyGiven(playerid)
{
     foreach(Player,i)//Using foreach
     {
         GivePlayerMoney(i,5000);
     }
     return 1;
}
Reply
#10

error 021: symbol already defined: "SetTimerEx"
error 017: undefined symbol "playerid"
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)