Blocking a command
#1

Well, i don't get this.

I have this:
pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(success)
    {
        if(pInEvent{playerid} == 1) return 0;
    }
    return 1;
}
The problem is that i can still use commands
And yes, i have 'pInEvent{playerid}' defined in the correct places.
Reply
#2

You sure you should have brackets, instead of whatever these are? [ and ]

pawn Код:
pInEvent{playerid}
should be

pawn Код:
pInEvent[playerid]
Reply
#3

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
You sure you should have brackets, instead of whatever these are? [ and ]

pawn Код:
pInEvent{playerid}
should be

pawn Код:
pInEvent[playerid]
That's not it, and it should be like that.
Reply
#4

pawn Код:
public OnPlayerCommandReceived( playerid, cmdtext[ ] )
{
    if ( pInEvent{ playerid } )
    {
        SendClientMessage( playerid, 0xFF000000, "You cannot use commands whilst in an event!" );
        return 0;
    }
    return 1;
}

public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
{
    return success;
}
Reply
#5

Quote:
Originally Posted by [L3th4l]
Посмотреть сообщение
That's not it, and it should be like that.
It is actually, Your coding isn't working, He's also told you where it is... Review it, and test it before saying it doesn't work

Код:
if(!IsPlayerConnected(i) || IsPlayerNPC(i) || !pConcerned[i]) continue;
		{
			if(pDKCount[i] >= 20) // High Kills
Notice they use normal brackets and square brackets... You have { } in your code.

Your code... is wrong.

and this guys...

Quote:
Originally Posted by bigcomfycouch
Посмотреть сообщение
pawn Код:
public OnPlayerCommandReceived( playerid, cmdtext[ ] )
{
    if ( pInEvent{ playerid } )
    {
        SendClientMessage( playerid, 0xFF000000, "You cannot use commands whilst in an event!" );
        return 0;
    }
    return 1;
}

public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
{
    return success;
}
is even wrong in the same area... Don't just copy paste and edit...
Reply
#6

Quote:

That's not it, and it should be like that.

You're trying to access an array's element. PlayerID being the subscript. What RealCop posted is correct. Seeing as you had that wrong, did you declare the variable properly? Are you setting it properly as well?

Also, I thought you would want to return true instead of false?
Reply
#7

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
It is actually, Your coding isn't working, He's also told you where it is... Review it, and test it before saying it doesn't work

Код:
if(!IsPlayerConnected(i) || IsPlayerNPC(i) || !pConcerned[i]) continue;
		{
			if(pDKCount[i] >= 20) // High Kills
Notice they use normal brackets and square brackets... You have { } in your code.

Your code... is wrong.

and this guys...



is even wrong in the same area... Don't just copy paste and edit...


Edit:
Quote:
Originally Posted by bigcomfycouch
Посмотреть сообщение
pawn Код:
public OnPlayerCommandReceived( playerid, cmdtext[ ] )
{
    if ( pInEvent{ playerid } )
    {
        SendClientMessage( playerid, 0xFF000000, "You cannot use commands whilst in an event!" );
        return 0;
    }
    return 1;
}

public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
{
    return success;
}
Straight to the point, thanks!
Reply
#8

Not to mention whether using which bracket is correct,
OnPlayerCommandReceived calls instantly when a player types a command(even if it's not exist)
OnPlayerCommandPerformed is called after searching for the commands,
and the success value is the value returned in that command(or is 0 when not found).
Reply
#9

Quote:
Originally Posted by [L3th4l]
Посмотреть сообщение
Straight to the point, thanks!
Stop using the squiggly brackets, and use the proper ones like we said. You can find time to post a goddamn animated gif, but you can't read your own code

WTF?

pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(success)
    {
        if([b]pInEvent{playerid} == 1[/b]) return 0;
    }
    return 1;
}
See, That bold piece, That's where your issue is, and it's because you use the { } brackets and not the ( ).
Reply
#10

Maybe he's not using it for an array? Ever think of that? -.-"
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)