A cmd that affects others.
#1

So i'm on my journey of scripting my own rp server. And I've come to a point where I want to create commands that'll affect other people. For example. I'm currently using the gTeam to create factions, i'd like to create a cmd that looks something like this:

/setfaction (playerid) (faction)

Get what I mean?

Anyways, thanks in advance!

Best regards
Facepunch
Reply
#2

I recommend you to use ZCMD & SSCANF2. It will be harder at the beginning but easier and more efficiently later.
Reply
#3

pawn Код:
if (strcmp(cmdtext,"/setfaction",true) == 0)
    {
        new playerid2;new factionid;
        tmp = strtok(cmdtext,idx);
        playerid = strval(tmp);
        if (!strlen(tmp)) return SendClientMessage(playerid,-1,"Use: /setfaction [playerid] [faction]");
       
        tmp = strtok(cmdtext,idx);
        factionid = strval(tmp);
        if (!strlen(tmp)) return SendClientMessage(playerid,-1,"Use: /setfaction [playerid] [faction]");
       
        // Functions to set playerid2 in a faction
        return true;
    }
Reply
#4

Quote:
Originally Posted by pantelimonfl
Посмотреть сообщение
I recommend you to use ZCMD & SSCANF2. It will be harder at the beginning but easier and more efficiently later.
I'll see if I can find any tutorials related to ZCMD and SSCANF2, if you have anything, that'd be great.


Quote:
Originally Posted by Dark.Angel
Посмотреть сообщение
pawn Код:
if (strcmp(cmdtext,"/setfaction",true) == 0)
    {
        new playerid2;new factionid;
        tmp = strtok(cmdtext,idx);
        playerid = strval(tmp);
        if (!strlen(tmp)) return SendClientMessage(playerid,-1,"Use: /setfaction [playerid] [faction]");
       
        tmp = strtok(cmdtext,idx);
        factionid = strval(tmp);
        if (!strlen(tmp)) return SendClientMessage(playerid,-1,"Use: /setfaction [playerid] [faction]");
       
        // Functions to set playerid2 in a faction
        return true;
    }
Could you explain to me further how this works?
I'm sorry, but i've never really worked with tmp and idx. My pawn says that tmp and idx isn't defined.
So since I have no experience in this field, I don't know how to define these two fellas.

Best regards,
FacePunch
Reply
#5

https://sampforum.blast.hk/showthread.php?tid=244841 i learnt them on this tut.
Reply
#6

Quote:
Originally Posted by pantelimonfl
Посмотреть сообщение
Thank you, this is perfect!

But I also thank you all for your help!

Kindest regards,
Facepunch
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)