Make for police skins only
#1

Can someone edit this script so only police officer skins (280 281 282 283 284 285 286 287 288 265 266 267) can use it. I will give +1 rep. Thanks in advance.



Код:
 #include <a_samp>

#include <SpikeStrip>

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;

}

public OnPlayerCommandText(playerid, cmdtext[])

{

new cmd[256];

new idx;

cmd = strtok(cmdtext, idx);

if (strcmp(cmd,"/createstrip",true) == 0)

{

new Float:plocx,Float:plocy,Float:plocz,Float:ploca;

GetPlayerPos(playerid, plocx, plocy, plocz);

GetPlayerFacingAngle(playerid,ploca);

CreateStrip(plocx,plocy,plocz,ploca);

return 1;

}

else if (strcmp(cmd,"/removestrip",true) == 0)

{

DeleteClosestStrip(playerid);

return 1;

}

else if (strcmp(cmd,"/removeallstrip",true) == 0)

{

DeleteAllStrip();

return 1;

}

return 0;

}
Reply
#2

Use this

pawn Код:
forward IsCopSkin(playerid);
public IsCopSkin(playerid)
{
    switch(GetPlayerSkin(playerid))
    {
      case 280, 281, 282, 283, 284, 285, 286, 287, 288, 265, 266, 267: return 1;
    }
    return 0;
}
Like this....

pawn Код:
if (strcmp(cmd,"/createstrip",true) == 0)
{
    if(IsCopSkin(playerid))
    {
        new Float:plocx,Float:plocy,Float:plocz,Float:ploca;
        GetPlayerPos(playerid, plocx, plocy, plocz);
        GetPlayerFacingAngle(playerid,ploca);
        CreateStrip(plocx,plocy,plocz,ploca);
    }
    return 1;
}
Reply
#3

here u go, works fine tested it
pawn Код:
#include <a_samp>
#include <SpikeStrip>
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;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
new idx;
cmd = strtok(cmdtext, idx);
if (strcmp(cmd,"/createstrip",true) == 0)
{
if(GetPlayerSkin(playerid) >= 280 && GetPlayerSkin(playerid) <= 288 || GetPlayerSkin(playerid) >= 265 && GetPlayerSkin(playerid) <= 267) {
new Float:plocx,Float:plocy,Float:plocz,Float:ploca;
GetPlayerPos(playerid, plocx, plocy, plocz);
GetPlayerFacingAngle(playerid,ploca);
CreateStrip(plocx,plocy,plocz,ploca);
}
return 1;
}
if (strcmp(cmd,"/removestrip",true) == 0)
{
if(GetPlayerSkin(playerid) >= 280 && GetPlayerSkin(playerid) <= 288 || GetPlayerSkin(playerid) >= 265 && GetPlayerSkin(playerid) <= 267) {
DeleteClosestStrip(playerid);
}
return 1;
}
if (strcmp(cmd,"/removeallstrip",true) == 0)
{
if(GetPlayerSkin(playerid) >= 280 && GetPlayerSkin(playerid) <= 288 || GetPlayerSkin(playerid) >= 265 && GetPlayerSkin(playerid) <= 267) {
DeleteAllStrip();
}
return 1;
}
return 0;
}
EDIT:Cyber already posted up ^
Reply
#4

Quote:
Originally Posted by XtremeR
Посмотреть сообщение
here u go, works fine tested it
pawn Код:
#include <a_samp>
#include <SpikeStrip>
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;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
new idx;
cmd = strtok(cmdtext, idx);
if (strcmp(cmd,"/createstrip",true) == 0)
{
if(GetPlayerSkin(playerid) >= 280 && GetPlayerSkin(playerid) <= 288 || GetPlayerSkin(playerid) >= 265 && GetPlayerSkin(playerid) <= 267) {
new Float:plocx,Float:plocy,Float:plocz,Float:ploca;
GetPlayerPos(playerid, plocx, plocy, plocz);
GetPlayerFacingAngle(playerid,ploca);
CreateStrip(plocx,plocy,plocz,ploca);
}
return 1;
}
if (strcmp(cmd,"/removestrip",true) == 0)
{
if(GetPlayerSkin(playerid) >= 280 && GetPlayerSkin(playerid) <= 288 || GetPlayerSkin(playerid) >= 265 && GetPlayerSkin(playerid) <= 267) {
DeleteClosestStrip(playerid);
}
return 1;
}
if (strcmp(cmd,"/removeallstrip",true) == 0)
{
if(GetPlayerSkin(playerid) >= 280 && GetPlayerSkin(playerid) <= 288 || GetPlayerSkin(playerid) >= 265 && GetPlayerSkin(playerid) <= 267) {
DeleteAllStrip();
}
return 1;
}
return 0;
}
How many calls to getplayerskin do you need? Don't you think saving it to a var and checking that var in that instance is better?
Reply
#5

well i think, yea thats better... but he should also learn a bit :3 anyways edited my prev. post
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)