/creategang help
#1

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;
Reply
#2

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
Reply
#3

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;
Reply
#4

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

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

Код:
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;
}
Reply
#7

Just change to strmid. Forgot about that function, lol
Reply
#8

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.
Reply
#9

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

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

That, or use sscanf!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)