Custom function - 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)
+--- Thread: Custom function (
/showthread.php?tid=399689)
Custom function -
Lz - 15.12.2012
pawn Code:
public HelpRequest(color,string[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if (PlayerInfo[pAdmin] ==1(i))
{
SendClientMessage(i, color, string);
}
}
}
return 1;
}
Trying to make this function so it sends a message to all the players whos pAdmin equals to the value of 1 (Helper value) But i keep getting these errors..
Code:
C:\Users\Scripting.Ash-PC\Desktop\Scripting\Roleplaying Server\gamemodes\roleplay.pwn(479) : error 029: invalid expression, assumed zero
C:\Users\Scripting.Ash-PC\Desktop\Scripting\Roleplaying Server\gamemodes\roleplay.pwn(479) : warning 215: expression has no effect
C:\Users\Scripting.Ash-PC\Desktop\Scripting\Roleplaying Server\gamemodes\roleplay.pwn(479) : error 001: expected token: ";", but found ")"
C:\Users\Scripting.Ash-PC\Desktop\Scripting\Roleplaying Server\gamemodes\roleplay.pwn(479) : error 029: invalid expression, assumed zero
C:\Users\Scripting.Ash-PC\Desktop\Scripting\Roleplaying Server\gamemodes\roleplay.pwn(479) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
Re: Custom function -
Djole1337 - 15.12.2012
pawn Code:
public HelpRequest(color, string[])
{
foreach(Player, i)
{
if(PlayerInfo[i][pAdmin] == 1)
{
SendClientMessage(i, color, string);
}
}
return 1;
}
or:
public HelpRequest(color, string[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdmin] == 1)
{
SendClientMessage(i, color, string);
}
}
}
return 1;
}
Re: Custom function -
Threshold - 15.12.2012
If I'm not mistaken, shouldn't this line:
pawn Code:
if (PlayerInfo[pAdmin] ==1(i))
Say something like:
pawn Code:
if (PlayerInfo[i][pAdmin] == 1)
??
If that doesn't fix it, try changing 'string[]' to 'const string[]'.
EDIT: Fuck, I nearly got it first.
Re: Custom function -
Mean - 15.12.2012
pawn Code:
stock HelpRequest(color, const string[]) {
for(new i = 0; i < MAX_PLAYERS; i++) {
if(IsPlayerConnected(i) && PlayerInfo[i][pAdmin] > 0) {
SendClientMessage(i, color, string);
}
}
return 1;
}
Re: Custom function -
Lz - 15.12.2012
Thanks all, I got one more problem when trying to add my script though..
pawn Code:
COMMAND:help(playerid, params[])
{
new message[28];
if (!sscanf(params, "s",message))
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof (name));
format(message, sizeof(message), "%s asks: %s", name, message);
HelpRequest(-1, message);
return 1;
}
Code:
C:\Users\Scripting.Ash-PC\Desktop\Scripting\Roleplaying Server\gamemodes\roleplay.pwn(282) : error 003: declaration of a local variable must appear in a compound block
C:\Users\Scripting.Ash-PC\Desktop\Scripting\Roleplaying Server\gamemodes\roleplay.pwn(282) : error 017: undefined symbol "name"
C:\Users\Scripting.Ash-PC\Desktop\Scripting\Roleplaying Server\gamemodes\roleplay.pwn(282) : warning 215: expression has no effect
C:\Users\Scripting.Ash-PC\Desktop\Scripting\Roleplaying Server\gamemodes\roleplay.pwn(282) : error 001: expected token: ";", but found "]"
C:\Users\Scripting.Ash-PC\Desktop\Scripting\Roleplaying Server\gamemodes\roleplay.pwn(282) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
Re: Custom function -
XStormiest - 15.12.2012
give us the 282 line
Re: Custom function -
Lordzy - 15.12.2012
pawn Code:
COMMAND:help(playerid, params[])
{
new message[128];
if (!sscanf(params, "s[128]",message))
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof (name));
format(message, sizeof(message), "%s asks: %s", name, message);
HelpRequest(-1, message);
return 1;
}
You must increase the string size first of all and also implement the size on sscanf "s" specifier.