SA-MP Forums Archive
Whats wrong here? - 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: Whats wrong here? (/showthread.php?tid=85714)



Whats wrong here? - Frankox - 09.07.2009

public OnPlayerCommandText(playerid, cmdtext[])
{
new sendername[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
new giveplayerid;

if(strcmp(cmdtext, "/givenrg", true) == 0)

LINE 107 new string[256], tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /give nrg [id]");
giveplayerid = strval(tmp);
{
if(IsPlayerConnected(giveplayerid))
{
GetPlayerName(playerid, sendername, sizeof(sendername));
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
format(string, sizeof(string), "%s(%i) Has get the NRG-500 by the admin!", sendername, playerid);
SendClientMessageToAll(giveplayerid, COLOR_RED, string);
new Floatcx, Floatcy, Floatcz;
GetPlayerePos(giveplayerid,scx, scy, scz);
SetVehiclePos(522,scx+1,scy+1,scz+1);
format(string, sizeof(string), "You have gave NRG-500 to a player%s(%i)", giveplayer, giveplayerid);
SendClientMessage(playerid, COLOR_RED, string);
GivePlayerMoney( playerid, 10000 );
}
else
{
format(string, sizeof(string), "SERVER: %d isn't connected", giveplayerid);
SendClientMessage(playerid, COLOR_WHITE, string);
}



return 1;
}
return 0;
}



D:\New Folder\GTA San Andreas\SAMP\SAMP SERVER\filterscripts\Givenrg.pwn(107) : error 003: declaration of a local variable must appear in a compound block
D:\New Folder\GTA San Andreas\SAMP\SAMP SERVER\filterscripts\Givenrg.pwn(107) : warning 217: loose indentation
D:\New Folder\GTA San Andreas\SAMP\SAMP SERVER\filterscripts\Givenrg.pwn(107) : error 017: undefined symbol "string"
D:\New Folder\GTA San Andreas\SAMP\SAMP SERVER\filterscripts\Givenrg.pwn(107) : warning 215: expression has no effect
D:\New Folder\GTA San Andreas\SAMP\SAMP SERVER\filterscripts\Givenrg.pwn(107) : error 001: expected token: ";", but found "]"
D:\New Folder\GTA San Andreas\SAMP\SAMP SERVER\filterscripts\Givenrg.pwn(107) : fatal error 107: too many error messages on one line


Re: Whats wrong here? - ledzep - 09.07.2009

You forgot an opening bracket "{" after the stcmp function.


Re: Whats wrong here? - Frankox - 09.07.2009

oh ok


Re: Whats wrong here? - Frankox - 09.07.2009

D:\New Folder\GTA San Andreas\SAMP\SAMP SERVER\filterscripts\Givenrg.pwn(10 : error 017: undefined symbol "strtok"
D:\New Folder\GTA San Andreas\SAMP\SAMP SERVER\filterscripts\Givenrg.pwn(10 : error 033: array must be indexed (variable "tmp")



line after line 107


Re: Whats wrong here? - ledzep - 09.07.2009

Put this somewhere in your code outside of any other functions/callbacks.

pawn Код:
stock strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}



Re: Whats wrong here? - Frankox - 09.07.2009

D:\New Folder\GTA San Andreas\SAMP\SAMP SERVER\filterscripts\Givenrg.pwn(164) : error 017: undefined symbol "idx"


Line after 108


Re: Whats wrong here? - ledzep - 09.07.2009

pawn Код:
new idx;



Re: Whats wrong here? - Frankox - 09.07.2009

new Float, Float:y, Float:z;
GetPlayerPos(giveplayerid,x, y, z);
CreateVehicle(522,x,y,z); Doesnt match a definition





Re: Whats wrong here? - Frankox - 09.07.2009

Now the problem is because i cant /givenrg ID


Re: Whats wrong here? - Frankox - 09.07.2009

new Float, Float:y, Float:z;
GetPlayerPos(giveplayerid,x, y, z);
CreateVehicle(522,x,y,z);