17.01.2016, 19:08
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.
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,
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.
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(!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:
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.
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.
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);
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!"))
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; } } }
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; }
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; } }
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:
Thanks for the advice, I'll improve my scripting and learn these two plugins.
|
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.