Little help please
#1

Hey guys.
How to make this like you can do /fheal armor

Because this give errors at this part:P

if(choice[playerid] == "health")

I'm out of mind once again
please help

pawn Код:
COMMAND:fheal(playerid,params[])
{
new choice;
if(funpoints[playerid]<8) return SendClientMessage(playerid, COLOR_DARKORANGE, "You need atleast 8 funpoints");
if(sscanf(params,"s",choice)) SendClientMessage(playerid, COLOR_DARKORANGE, "HINT: /fheal [health/armor]");
else
{
if(choice[playerid] == "health")
{

}
}
return 1;
}
Код:
C:\Users\Michael\Desktop\Samp scvripting\filterscripts\funpoints.pwn(189) : error 028: invalid subscript (not an array or too many subscripts): "choice"
C:\Users\Michael\Desktop\Samp scvripting\filterscripts\funpoints.pwn(189) : warning 215: expression has no effect
C:\Users\Michael\Desktop\Samp scvripting\filterscripts\funpoints.pwn(189) : error 001: expected token: ";", but found "]"
C:\Users\Michael\Desktop\Samp scvripting\filterscripts\funpoints.pwn(189) : error 029: invalid expression, assumed zero
C:\Users\Michael\Desktop\Samp scvripting\filterscripts\funpoints.pwn(189) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#2

choice has to be a string

Код:
new choice[10]
Before the hint message (SendClientM....) you need to put return, like above (not sure about this one)
also, in sscanf where there's "s" you need to put "s[10]".


I hope I help
Reply
#3

Okay there's a few problems with your command, please read the comments in this fixed code:

pawn Код:
COMMAND:fheal(playerid,params[])
{
    new choice[20]; // You need to initialize it as an array, as it requires multiple cells to hold each character in the string
    if(funpoints[playerid]<8) return SendClientMessage(playerid, COLOR_DARKORANGE, "You need atleast 8 funpoints");
    if(sscanf(params,"s",choice)) SendClientMessage(playerid, COLOR_DARKORANGE, "HINT: /fheal [health/armor]");
    else
    {
        if(!strcmp(choice,"health",true)) // Pawn does not allow direct comparisons of strings, you must use the strcmp function
        {

        }
    }
    return 1;
}
Reply
#4

Ah guys. Now I remember it again.
Thankyou so much.

I started scripting again since a week so. I have to get warmed up again :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)