# command without "/"
#1

i want to make a command so when a a player is in a checkpoint with out the "/" and number 1 - 10 etc...

so when a player enters a checkpoint, instead of using /blabla 1 then can just type 1.

Thanks for any ideas!!!
Reply
#2

pawn Код:
//global
new enableCmd[MAX_PLAYERS]; //the toggle variable for us to use
pawn Код:
//OnPlayerEnterCheckpoint
enableCmd[playerid] = 1; //make it possible for player to use the command if he enters the checkpoint
pawn Код:
//OnPlayerExitCheckpoint
enableCmd[playerid] = 0; //make it impossible for player to use the command if he leaves the checkpoint
pawn Код:
//OnPlayerText
if(enableCmd[playerid] && IsPlayerInCheckpoint(playerid))
{
    if(!strcmp(text, "1", true))
    {
        //stuff if player types 1
    }
    //continue making for the other numbers
}
I hope it helped!
Reply
#3

Whoah! your one of the only people that actually helped!! man thanks allot, i would have never figured that out! again Thanks!
I vote you the most helpful person on sa-mp forum!!!
Reply
#4

well thanks, and no problem
Reply
#5

one question , could i do this, it would be a little easier:

pawn Код:
//OnPlayerText
if(enableCmd[playerid] && IsPlayerInCheckpoint(playerid))
{
    if(!strcmp(text, "", true))
    {
        switch(text)
        {
            case 1: // player typed in 1
            case 2: // player typed in 2
            etc.....
        }
    }
}
would that work?

EDIT: also how can i stop the "1" from displaying? it says on chat "Ethan: 1" when i do it, can i stop that?
Reply
#6

pawn Код:
//OnPlayerText
if(enableCmd[playerid] && IsPlayerInCheckpoint(playerid))
{
    switch(strval(text))
    {
            case 1: // player typed in 1
            case 2: // player typed in 2
            etc.....
    }
}
I believe that should work..
Reply
#7

also how can i stop the "1" from displaying? it says on chat "Ethan: 1" when i do it, can i stop that?

i put an edit but i just replied again in case you didn't see it
Reply
#8

Oops sorry for that... :P
Add
pawn Код:
return 0;
underneath the closing brace ( } ) for the switch statement
Reply
#9

lol i was just gonna say i figured it out, that was the logical thing to do so i did that and it works! Again Thanks!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)