SA-MP Forums Archive
# command without "/" - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: # command without "/" (/showthread.php?tid=71228)



# command without "/" - StrickenKid - 30.03.2009

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!!!


Re: # command without "/" - LarzI - 30.03.2009

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!


Re: # command without "/" - StrickenKid - 30.03.2009

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!!!


Re: # command without "/" - LarzI - 30.03.2009

well thanks, and no problem


Re: # command without "/" - StrickenKid - 30.03.2009

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?


Re: # command without "/" - LarzI - 30.03.2009

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..


Re: # command without "/" - StrickenKid - 30.03.2009

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


Re: # command without "/" - LarzI - 30.03.2009

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


Re: # command without "/" - StrickenKid - 30.03.2009

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!