PDA

View Full Version : cmds


Jaua10
11/07/2018, 05:35 PM
Guys im making two new commands for admin but gives me this error:

C:\Users\Jaua\Downloads\samp037_svr_R2-1-1_win32\gamemodes\baserp.pwn(2262) : error 017: undefined symbol "tmp"
C:\Users\Jaua\Downloads\samp037_svr_R2-1-1_win32\gamemodes\baserp.pwn(2262) : error 017: undefined symbol "strtok"
C:\Users\Jaua\Downloads\samp037_svr_R2-1-1_win32\gamemodes\baserp.pwn(2263) : error 017: undefined symbol "tmp"
C:\Users\Jaua\Downloads\samp037_svr_R2-1-1_win32\gamemodes\baserp.pwn(2275) : error 017: undefined symbol "tmp"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.


CMD:addcomponent(playerid, params[])
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pAdmin] > 5)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /addcomponent [ComponentID]");
return 1;
}
if(!IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, COLOR_CORRECTION, "You are not in a vehicle !");
return 1;
}
{
new componentid;
componentid = strval(tmp);
new CarId = GetPlayerVehicleID(playerid);
if(componentid < 1000 || componentid > 1193) { SendClientMessage(playerid, COLOR_CORRECTION, "Component ID can't be below 1000 or above 1193 !"); return 1; }
AddVehicleComponent(CarId, componentid);
SendClientMessage(playerid, COLOR_WHITE, " USAGE: /carcomponents for more info !");
}
}
else
{
SendClientMessage(playerid, COLOR_CORRECTION, "You are not authorized to use this command !");
return 1;
}
}
return 1;
}

any suggestion?

ItsRobinson
11/07/2018, 05:39 PM
new tmp = strtok(cmdtext, idx);

instead of

tmp = strtok(cmdtext, idx);

and read this

http://forum.sa-mp.com/showthread.php?t=345137

Jaua10
11/07/2018, 05:51 PM
C:\Users\Jaua\Downloads\samp037_svr_R2-1-1_win32\gamemodes\baserp.pwn(2262) : error 017: undefined symbol "strtok"
C:\Users\Jaua\Downloads\samp037_svr_R2-1-1_win32\gamemodes\baserp.pwn(2263) : error 035: argument type mismatch (argument 1)
C:\Users\Jaua\Downloads\samp037_svr_R2-1-1_win32\gamemodes\baserp.pwn(2275) : error 035: argument type mismatch (argument 1)
C:\Users\Jaua\Downloads\samp037_svr_R2-1-1_win32\gamemodes\baserp.pwn(2262) : warning 204: symbol is assigned a value that is never used: "tmp"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.


when i try to put what i see in the link, pawno crashes

diego200052
11/07/2018, 06:30 PM
Read this: http://wiki.sa-mp.com/wiki/Strtok

Florin48
11/07/2018, 06:49 PM
use sscanf is more better

Jaua10
11/07/2018, 07:02 PM
C:\Users\Jaua\Downloads\samp037_svr_R2-1-1_win32\gamemodes\baserp.pwn(2262) : error 017: undefined symbol "cmdtext"
C:\Users\Jaua\Downloads\samp037_svr_R2-1-1_win32\gamemodes\baserp.pwn(2262) : error 033: array must be indexed (variable "-unknown-")
C:\Users\Jaua\Downloads\samp037_svr_R2-1-1_win32\gamemodes\baserp.pwn(2263) : error 035: argument type mismatch (argument 1)
C:\Users\Jaua\Downloads\samp037_svr_R2-1-1_win32\gamemodes\baserp.pwn(2275) : error 035: argument type mismatch (argument 1)
C:\Users\Jaua\Downloads\samp037_svr_R2-1-1_win32\gamemodes\baserp.pwn(2262) : warning 204: symbol is assigned a value that is never used: "tmp"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.


CMD:addcomponent(playerid, params[])
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pAdmin] > 5)
{
new tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /addcomponent [ComponentID]");
return 1;
}
if(!IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, COLOR_CORRECTION, "You are not in a vehicle !");
return 1;
}
{
new componentid;
componentid = strval(tmp);
new CarId = GetPlayerVehicleID(playerid);
if(componentid < 1000 || componentid > 1193) { SendClientMessage(playerid, COLOR_CORRECTION, "Component ID can't be below 1000 or above 1193 !"); return 1; }
AddVehicleComponent(CarId, componentid);
SendClientMessage(playerid, COLOR_WHITE, " USAGE: /carcomponents for more info !");
}
}
else
{
SendClientMessage(playerid, COLOR_CORRECTION, "You are not authorized to use this command !");
return 1;
}
}
return 1;
}
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;
}
CMD:carcomponents(playerid, params[])
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pAdmin] > 5)
{
SendClientMessage(playerid, COLOR_GREEN, "|___________| CAR COMPONENTS LIST |___________|");
SendClientMessage(playerid, COLOR_WHITE, "x10 Nos - 1010");
SendClientMessage(playerid, COLOR_WHITE, "Shadow Rims - 1073");
SendClientMessage(playerid, COLOR_WHITE, "Mega Rims - 1074");
SendClientMessage(playerid, COLOR_WHITE, "Rimshine Rims- 1075");
SendClientMessage(playerid, COLOR_WHITE, "Wires Rims - 1076");
SendClientMessage(playerid, COLOR_WHITE, "Classic Rims - 1077");
SendClientMessage(playerid, COLOR_WHITE, "Twist Rims - 1078");
SendClientMessage(playerid, COLOR_WHITE, "Cutter Rims - 1079");
SendClientMessage(playerid, COLOR_WHITE, "Switch Rims - 1080");
SendClientMessage(playerid, COLOR_WHITE, "Grove Rims - 1081");
SendClientMessage(playerid, COLOR_WHITE, "Import Rims - 1082");
SendClientMessage(playerid, COLOR_WHITE, "Dollar Rims - 1083");
SendClientMessage(playerid, COLOR_WHITE, "Trance Rims - 1084");
SendClientMessage(playerid, COLOR_WHITE, "Atomic Rims - 1085");
SendClientMessage(playerid, COLOR_WHITE, "Hydraulics - 1087");
SendClientMessage(playerid, COLOR_GREEN, "______________________________________________");
}
else
{
SendClientMessage(playerid, COLOR_CORRECTION, "You are not authorized to use this command !");
return 1;
}
}
return 1;
}

RedRex
11/07/2018, 07:04 PM
Put this into your codes!!

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;
}

for tmp read this! http://forum.sa-mp.com/showthread.php?t=231496

Sew_Sumi
11/07/2018, 07:19 PM
The better solution, is to not use out of date code, and to not copy-paste/mutilate other scripts, simply to throw it all into your gamemode.


Before long you'll encounter error after error and find it harder and harder as the script starts to stack up with shit, and then you'll be wondering before long why your script is slowing down, and getting harder to get people to give you copy-paste fixes.

Jaua10
11/07/2018, 08:59 PM
Reading the topic i remplace but now i go this errors:

C:\Users\Jaua\Downloads\samp037_svr_R2-1-1_win32\gamemodes\baserp.pwn(2281) : warning 202: number of arguments does not match definition
C:\Users\Jaua\Downloads\samp037_svr_R2-1-1_win32\gamemodes\baserp.pwn(2281) : error 006: must be assigned to an array
C:\Users\Jaua\Downloads\samp037_svr_R2-1-1_win32\gamemodes\baserp.pwn(2282) : error 035: argument type mismatch (argument 1)
C:\Users\Jaua\Downloads\samp037_svr_R2-1-1_win32\gamemodes\baserp.pwn(2281) : warning 204: symbol is assigned a value that is never used: "tmp"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.


my script

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;
}
CMD:addcomponent(playerid, params[])
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pAdmin] > 5)
{
new tmp;
tmp = strtok( params );
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /addcomponent [ComponentID]");
return 1;
}
if(!IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, COLOR_CORRECTION, "You are not in a vehicle !");
return 1;
}
{
new componentid;
componentid = strval( params );
new CarId = GetPlayerVehicleID(playerid);
if(componentid < 1000 || componentid > 1193) { SendClientMessage(playerid, COLOR_CORRECTION, "Component ID can't be below 1000 or above 1193 !"); return 1; }
AddVehicleComponent(CarId, componentid);
SendClientMessage(playerid, COLOR_WHITE, " USAGE: /carcomponents for more info !");
}
}
else
{
SendClientMessage(playerid, COLOR_CORRECTION, "You are not authorized to use this command !");
return 1;
}
}
return 1;
}

ItsRobinson
11/07/2018, 09:04 PM
new tmp, idx;

tmp = strtok(params, idx);

Jaua10
11/07/2018, 09:25 PM
C:\Users\Jaua\Downloads\samp037_svr_R2-1-1_win32\gamemodes\baserp.pwn(2281) : error 006: must be assigned to an array
C:\Users\Jaua\Downloads\samp037_svr_R2-1-1_win32\gamemodes\baserp.pwn(2282) : error 035: argument type mismatch (argument 1)
C:\Users\Jaua\Downloads\samp037_svr_R2-1-1_win32\gamemodes\baserp.pwn(2281) : warning 204: symbol is assigned a value that is never used: "tmp"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.


i already put it and shows me the same 2 errrors

ItsRobinson
11/07/2018, 09:31 PM
CMD:addcomponent(playerid, params[])
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pAdmin] > 5)
{
new componentid;
if(sscanf(params, "d", componentid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /addcomponent [ComponentID]");

if(!IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, COLOR_CORRECTION, "You are not in a vehicle !");
return 1;
}

new CarId = GetPlayerVehicleID(playerid);
if(componentid < 1000 || componentid > 1193) { SendClientMessage(playerid, COLOR_CORRECTION, "Component ID can't be below 1000 or above 1193 !"); return 1; }
AddVehicleComponent(CarId, componentid);
SendClientMessage(playerid, COLOR_WHITE, " USAGE: /carcomponents for more info !");
}
else
{
SendClientMessage(playerid, COLOR_CORRECTION, "You are not authorized to use this command !");
return 1;
}
}
return 1;
}



Your codes giving me aids, use sscanf

Jaua10
11/07/2018, 09:35 PM
CMD:addcomponent(playerid, params[])
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pAdmin] > 5)
{
new componentid;
if(sscanf(params, "d", componentid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /addcomponent [ComponentID]");

if(!IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, COLOR_CORRECTION, "You are not in a vehicle !");
return 1;
}

new CarId = GetPlayerVehicleID(playerid);
if(componentid < 1000 || componentid > 1193) { SendClientMessage(playerid, COLOR_CORRECTION, "Component ID can't be below 1000 or above 1193 !"); return 1; }
AddVehicleComponent(CarId, componentid);
SendClientMessage(playerid, COLOR_WHITE, " USAGE: /carcomponents for more info !");
}
else
{
SendClientMessage(playerid, COLOR_CORRECTION, "You are not authorized to use this command !");
return 1;
}
}
return 1;
}



Your codes giving me aids, use sscanf

I am new in this just like 1 and a half week, what am i using? thats not sscanf?

Sew_Sumi
12/07/2018, 02:20 AM
I am new in this

You're doing surprisingly well for giving information out when requested.