SA-MP Forums Archive
a small question - 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: a small question (/showthread.php?tid=81255)



a small question - _diana_ - 09.06.2009

Hi!,

well as it says above i'm wanting to ask a small question, i get some errors which of course i don't understand *shame* lol but maybe someone could help a girl out? lmao

this is line 1109:

format(string,sizeof(string),"Has invitado a %s (id:%d) para que tenga un duelo contigo, espera a que acepte tu invitacion.",playername(player2),(player2));


the errors i get are (apart from the warning):

Xenon.pwn(1109) : error 012: invalid function call, not a valid address
Xenon.pwn(1109) : warning 215: expression has no effect
Xenon.pwn(1109) : error 001: expected token: ";", but found ")"
Xenon.pwn(1109) : error 029: invalid expression, assumed zero


any thoughts? =)

if more code needed please tell me (=



Re: a small question - dice7 - 09.06.2009

Shouldn't 'playername' be an array ?


Re: a small question - _diana_ - 09.06.2009

lmao how do i do that? (ye i know kinda dumb question but hey!, you never learn if you never ask!)


Re: a small question - MPKaboose - 09.06.2009

pawn Код:
new playername[24];
24 is the array size


Re: a small question - hansen111 - 09.06.2009

Assuming that you have an array called playername[MAX_PLAYERS][namelength]
Assuming that player2 is a playerid

format(string,sizeof(string),"Has invitado a %s (id:%d) para que tenga un duelo contigo, espera a que acepte tu invitacion.",playername[player2],player2);



Re: a small question - MPKaboose - 09.06.2009

playername[MAX_PLAYERS] thats wrong
pawn Код:
new playername[MAX_PLAYERS][24];
since this will hold a string (players name) if I am correct


Re: a small question - hansen111 - 09.06.2009

Quote:
Originally Posted by xoɟɔıʇɔɹɐ
pawn Код:
new playername[24];
24 is the array size
This will be errored if the server has more than 25 players.

//playerid > 24
playername[playerid] <- error index out of bounds

better do:
pawn Код:
new playername[MAX_PLAYERS][50];
200 is the array size and will also work on future versions of samp if the max players val gets adjusted. It will hold names of 50 charecters, but u can adjust off course



Re: a small question - _diana_ - 09.06.2009

oh!, i'm not sure if i'm aloud to post the code, i'm sorry if i seem a bit u know lol



if(strcmp(cmd, "/duelo", true) == 0)
{
new Comando[256];
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
Comando = strtok(cmdtext, idx);

new gangcmd = 3;

if(!strlen(Comando))
{
SendClientMessage(playerid, COLOR_WHITE,"USA: /Duelo [Retar/Aceptar/Entrar].");
return 1;
}

if(strcmp(Comando, "retar", true) == 0) gangcmd = 1;
if(strcmp(Comando, "aceptar", true) == 0) gangcmd = 2;
if(gangcmd > 2)
{
SendClientMessage(playerid, COLOR_WHITE, "USA: /Duelo [Retar/Aceptar/Entrar].");
return 1;
}
if(gangcmd < 0)
{
SendClientMessage(playerid, COLOR_WHITE, "USA: /Duelo [Retar/Aceptar/Entrar].");
return 1;
}
if(gangcmd == 1)
{
new inv[256];
inv = strtok(cmdtext, idx);
new player2 = strval(inv);

if(!strlen(inv))
{
SendClientMessage(playerid, COLOR_WHITE, "USO: '/duelo [retar] [id].");
return 1;
}

if (!IsPlayerConnected(player2))
return SendClientMessage(playerid, COLOR_WHITE, "Ese jugador no esta conectado.");

if(player2 == playerid)
return SendClientMessage(playerid, COLOR_WHITE, "No puedes tener un duelo contigo mismo!");

if(DuelInfo[player2][Invitado] == 2)
return SendClientMessage(playerid, COLOR_WHITE, "Ese jugador ya esta en un duelo!");

format(string,sizeof(string),"Has invitado a %s (id:%d) para que tenga un duelo contigo, espera a que acepte tu invitacion.",playername(player2),(player2));
SendClientMessage(playerid,COLOR_WHITE, string);

format(string,sizeof(string),"Has sido invitado por %s (ID:%d) para tener un duelo.",playername(playerid),(playerid));
SendClientMessage(player2,COLOR_WHITE, string);
SendClientMessage(player2,COLOR_WHITE, "Usa /duelo aceptar [id] para aceptar el duelo");

DuelInfo[player2][Invitado] = 1;
DuelInfo[player2][InvitadoPor] = playerid;
return 1;
}


Re: a small question - MPKaboose - 09.06.2009

The player's name will never have the size of 200 you will use the remaining string size for nothing ****** made a post about why not to use big string sizes if not needed also playername[MAX_PLAYERS][24]; will store all usrs name with the size of 24 cells also if you want to make it like that just use MAX_PLAYER_NAME instead of 24


Re: a small question - hansen111 - 09.06.2009

Wrong:
format(string,sizeof(string),"Has invitado a %s (id:%d) para que tenga un duelo contigo, espera a que acepte tu invitacion.",playername(player2),(player2));


Right:
format(string,sizeof(string),"Has invitado a %s (id:%d) para que tenga un duelo contigo, espera a que acepte tu invitacion.",playername[player2],player2);