SA-MP Forums Archive
/creategang help - 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: /creategang help (/showthread.php?tid=174636)



/creategang help - mrcoolballs - 06.09.2010

Im trying to create my own gang system but when i do /creategang it does everything correct except it doesnt show the name

pawn Код:
dcmd_gangcreate(playerid, params[])
{
    new string[128],n[MAX_PLAYER_NAME],name;
    GetPlayerName(playerid,n,sizeof(n));
    name = strval(params);
    if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /gangcreate <Name>");
    GangID ++;
    GangInfo[playerid][Leader] = n;
    GangInfo[playerid][Name] = name;
    format(string,sizeof(string),"%s has just created the gang %s(ID %d)",n,name,GangID);
    SendClientMessageToAll(ORANGE,string);
    return 1;
}
Like the ID gets set properly but the name doesn't when i type /creategang Cool_Gang it will say I just created the gang (nothing) ID 1
how do i do this? also heres the enum i used to store the variables in:

pawn Код:
enum pGangInfo
    {
    Name[60],
    Leader[24],
    Banned
    };
new GangInfo[MAX_PLAYERS][pGangInfo];
new GangID = -1;



Re: /creategang help - LarzI - 06.09.2010

pawn Код:
dcmd_gangcreate(playerid, params[])
{
    new string[128],n[MAX_PLAYER_NAME];
    GetPlayerName(playerid,n,sizeof(n));
    if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /gangcreate <Name>");
    GangID ++;
    GangInfo[playerid][Leader] = n;
    GangInfo[playerid][Name] = params;
    format(string,sizeof(string),"%s has just created the gang %s(ID %d)",n,params,GangID);
    SendClientMessageToAll(ORANGE,string);
    return 1;
}

Or my version:

pawn Код:
dcmd_gangcreate(playerid, params[])
{  
    new string[ 128 ], n[MAX_PLAYER_NAME];
    GetPlayerName( playerid, n, sizeof( n ));
    if( isnull( params ))
        return SendClientMessage( playerid, GREY, "USAGE: /gangcreate <Name>" );
    GangID ++;
    GangInfo[playerid][Leader] = n;
    GangInfo[playerid][Name] = params;
    format( string, sizeof( string ), "%s has just created the gang %s(ID %d)", n, params, GangID );
    SendClientMessageToAll( ORANGE, string );
    return true;
}


This forum requires that you wait 120 seconds between posts. Please try again in 11 seconds. BLARGH


Re: /creategang help - mrcoolballs - 06.09.2010

wait i get an error:error 047: array sizes do not match, or destination array is too small
this is the line:
pawn Код:
GangInfo[playerid][Name] = params;



Re: /creategang help - LarzI - 06.09.2010

Ah, change to
pawn Код:
format( GangInfo[playerid][Name], sizeof( GangInfo[playerid][Name] ), "%s", params );



Re: /creategang help - ivex - 06.09.2010

Quote:
Originally Posted by LarzI
Посмотреть сообщение
Ah, change to
pawn Код:
format( GangInfo[playerid][Name], sizeof( GangInfo[playerid][Name] ), "%s", params );
Yes or use strmid


Re: /creategang help - mrcoolballs - 06.09.2010

Код:
error 047: array sizes do not match, or destination array is too small
 expected token: "]", but found "-identifier-"
 warning 215: expression has no effect
 error 001: expected token: ";",  error 029: invalid expression, assumed zero
 fatal error 107: too many error messages on one line
i get those errors now, all on line 116 which is the format( GangInfo[playerid][Name],sieof(GangInfo[playerid][Name]...
?

heres the current code:
pawn Код:
dcmd_gangcreate(playerid, params[])
{
    new string[128],n[MAX_PLAYER_NAME],name;
    GetPlayerName(playerid,n,sizeof(n));
    name = strval(params);
    if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /gangcreate <Name>");
    GangID ++;
    GangInfo[playerid][Leader] = n;
    GangInfo[playerid][Name] = params;
    format( GangInfo[playerid][Name], sizeof( GangInfo[playerid][Name] ), "%s", params );
    SendClientMessageToAll(ORANGE,string);
    return 1;
}



Re: /creategang help - LarzI - 06.09.2010

Just change to strmid. Forgot about that function, lol


Re: /creategang help - Toni - 06.09.2010

Btw, this VERY easy to solve
You put name = strval(params);

Which means you are telling your script to search for a number or value, not a string.

You can also just copy the first one you had, and change name = strval(params); to name = strtok(tmp...idx); something like that.


Re: /creategang help - LarzI - 06.09.2010

Why use strtok with dcmd? That's just retarded.


Re: /creategang help - Toni - 06.09.2010

Quote:
Originally Posted by LarzI
Посмотреть сообщение
Why use strtok with dcmd? That's just retarded.
Idnno, i was using a example..

That, or use sscanf!