PDA

View Full Version : cmd


ShaggyShaggy
06/07/2019, 07:12 AM
new specplayerid, specvehicleid, idx;
if(!IsPlayerAdmin(playerid)) return 0;

cmd = strtok(cmdtext, idx);

if(strcmp(cmd, "/specplayer", true) == 0) {
new tmp[256];
tmp = strtok(cmdtext, idx);

if(!strlen(tmp)) {
SendClientMessage(playerid, alb, "Folosire: /specplayer [id player]");
return 1;
}
specplayerid = strval(tmp);

if(!IsPlayerConnected(specplayerid)) {
SendClientMessage(playerid, auriu, "Player nu este activ!");
return 1;
}

TogglePlayerSpectating(playerid, 1);
PlayerSpectatePlayer(playerid, specplayerid);
SetPlayerInterior(playerid,GetPlayerInterior(specp layerid));
gSpectateID[playerid] = specplayerid;
gSpectateType[playerid] = ADMIN_SPEC_TYPE_PLAYER;

return 1;
}

if(strcmp(cmd, "/specvehicle", true) == 0) {
new tmp[256];
tmp = strtok(cmdtext, idx);


386-414 lines

C:\Users\Gabi\Desktop\Samp Server\CotnariRoleplayBeta.pwn(386) : error 017: undefined symbol "strtok"
C:\Users\Gabi\Desktop\Samp Server\CotnariRoleplayBeta.pwn(386) : error 033: array must be indexed (variable "cmd")
C:\Users\Gabi\Desktop\Samp Server\CotnariRoleplayBeta.pwn(390) : error 017: undefined symbol "strtok"
C:\Users\Gabi\Desktop\Samp Server\CotnariRoleplayBeta.pwn(390) : error 033: array must be indexed (variable "tmp")
C:\Users\Gabi\Desktop\Samp Server\CotnariRoleplayBeta.pwn(414) : error 017: undefined symbol "strtok"
C:\Users\Gabi\Desktop\Samp Server\CotnariRoleplayBeta.pwn(414) : error 033: array must be indexed (variable "tmp")
C:\Users\Gabi\Desktop\Samp Server\CotnariRoleplayBeta.pwn(383) : warning 203: symbol is never used: "idx"

MBilal
06/07/2019, 07:27 AM
new specplayerid, specvehicleid, idx;
if(!IsPlayerAdmin(playerid)) return 0;

cmd = strtok(cmdtext, idx);

if(strcmp(cmd, "/specplayer", true) == 0) {
new tmp[256];
tmp = strtok(cmdtext, idx);

if(!strlen(tmp)) {
SendClientMessage(playerid, alb, "Folosire: /specplayer [id player]");
return 1;
}
specplayerid = strval(tmp);

if(!IsPlayerConnected(specplayerid)) {
SendClientMessage(playerid, auriu, "Player nu este activ!");
return 1;
}

TogglePlayerSpectating(playerid, 1);
PlayerSpectatePlayer(playerid, specplayerid);
SetPlayerInterior(playerid,GetPlayerInterior(specp layerid));
gSpectateID[playerid] = specplayerid;
gSpectateType[playerid] = ADMIN_SPEC_TYPE_PLAYER;

return 1;
}

if(strcmp(cmd, "/specvehicle", true) == 0) {
new tmp[256];
tmp = strtok(cmdtext, idx);


386-414 lines

C:\Users\Gabi\Desktop\Samp Server\CotnariRoleplayBeta.pwn(386) : error 017: undefined symbol "strtok"
C:\Users\Gabi\Desktop\Samp Server\CotnariRoleplayBeta.pwn(386) : error 033: array must be indexed (variable "cmd")
C:\Users\Gabi\Desktop\Samp Server\CotnariRoleplayBeta.pwn(390) : error 017: undefined symbol "strtok"
C:\Users\Gabi\Desktop\Samp Server\CotnariRoleplayBeta.pwn(390) : error 033: array must be indexed (variable "tmp")
C:\Users\Gabi\Desktop\Samp Server\CotnariRoleplayBeta.pwn(414) : error 017: undefined symbol "strtok"
C:\Users\Gabi\Desktop\Samp Server\CotnariRoleplayBeta.pwn(414) : error 033: array must be indexed (variable "tmp")
C:\Users\Gabi\Desktop\Samp Server\CotnariRoleplayBeta.pwn(383) : warning 203: symbol is never used: "idx"

Add this some where in gamemode

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



https://wiki.sa-mp.com/wiki/Strtok

ShaggyShaggy
09/07/2019, 09:51 AM
Thanks +rep