Scripting Problem, explanation requested.
#4

Beside the fact that you can't use the same callback twice, you have made several other mistakes.

First of all, I would recommend taking a looking here https://sampwiki.blast.hk/wiki/Category...es_.28pVars.29 to get familiar with SA-MP's functions & natives.


Now lets get on with your code.

Код:
if new string1[] = (IsPlayerPos, playerid 0,1575.8651,-1690.4974,6.2188,359.9606,0,0,0,0,0,0);
What's the point of defining string as a variable here then typing that right after it ? a string is a sequence of characters, either as a literal constant or as some kind of variable - So there's no point of assigning a string to those type of numbers.


When you take a look at the wiki, you'll notice that there's a function called IsPlayerInRangeOfPoint - I'll tell you how to use it later on,

Код:
if(!strcmp(string1, false, SendClientMessage "You must be at duty point!"))
Not how it works either.

In PAWN [and most coding languages] - we use if & elseif. Its quite logical, The code detects "IF" a certain condition is happening, if its not - then "else if" something else will happen.

So here's how your code should look like.

Код:
if(!strcmp(cmdtext, "/duty")) 
{
   if(!IsPlayerInRangeOfPoint(playerid 0,1575.8651,-1690.4974,6.2188,359.9606,0,0,0,0,0,0)) return     SendClientMessage(playerid, -1,  You're not at the duty location!");
   {
     if(!(pTeam[playerid] == team_cops)) return SendClientMessage(playerid, -1, "You cant use this!");
     {
        SetPlayerSkin(playeid, 300) 
        SendClientMessage(playerid, 0xFFFFFFFF, "You've gone on duty"); 
        return 1;
     }
  }
}
I've written this code on my phone so I am not so sure if everything is correct but that's how it should generally look, plus I haven't checked any of the parameters of your IsPlayerInRangeOfPoint.

Same thing for this code tho.

Код:
     if(!strcmp(cmdtext, "/lspdadminset")) 
     { 
        if(!IsPlayerConnected(i) || IsPlayerAdmin(i))continue; 
        SendClientMessage(playerid, 0xFFFFFFFF, "You're LSPD now!"); 
        pTeam[playerid] = team_lspd; 
        return 1; 
     }
if(!IsPlayerConnected(i) <- You dont need to use i as its not defined, playerid is defined by default to retrieve the ID of the player who typed the command so you'd use if(!IsPlayerConnected(playerid))

No point of using continue; either - you'd just use brackets to keep going.

So your code should look something like this:

Код:
     if(!strcmp(cmdtext, "/lspdadminset")) 
     { 
        if(!IsPlayerConnected(playerid) || IsPlayerAdmin(playerid))
        {
        SendClientMessage(playerid, 0xFFFFFFFF, "You're LSPD now!"); 
        pTeam[playerid] = team_lspd; 
        return 1; 
        }
     }
Keep in mind that "||" will search if either of the statements are true NOT both and if one of them is, it will keep going, so in your situation, I would recommend using "&&" as it checks if both statements are true.

I would also HIGHLY recommend using sscanf & ZCMD, beside the fact that they are so much faster, its ALOT easier to understand and use them than strcmp and strtok especially that you're still learning.


Quote:
Originally Posted by DRP
Посмотреть сообщение
Thanks for the advice, I'll improve my scripting and learn these two plugins.
There's a difference between a callback, function & a plugin.

These are the plugins: http://forum.sa-mp.com/forumdisplay.php?f=18

If you're really serious about wanting to learn how to script - I would start with reading this documentary http://www.compuphase.com/pawn/Pawn_Language_Guide.pdf - it covers everything about PAWN and its REALLY helpful.
Reply


Messages In This Thread
Scripting Problem, explanation requested. - by DRP - 17.01.2016, 17:16
Re: Scripting Problem, explanation requested. - by PrO.GameR - 17.01.2016, 17:42
Re: Scripting Problem, explanation requested. - by DRP - 17.01.2016, 18:00
Re: Scripting Problem, explanation requested. - by -CaRRoT - 17.01.2016, 19:08
Re: Scripting Problem, explanation requested. - by DRP - 18.01.2016, 05:33

Forum Jump:


Users browsing this thread: 1 Guest(s)