SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 04/04/2010, 06:41 PM   #1
Torran
High-roller
 
Join Date: Jan 2010
Posts: 1,794
Reputation: 1
Default [TUT] How to stop command abusing

Welcome to my very short and simple tutorial!

Credits to Joe_Staff for the code!

For SAMP Default
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp...
{
if(GetPVarInt(playerid,"CMDABUSE")>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"You must wait before using a command");
SetPVarInt(playerid,"CMDABUSE",GetTickCount()+5000);
// REST OF CODE
return 1;
}

For DCMD
pawn Code:
dcmd_....
{
if(GetPVarInt(playerid,"CMDABUSE")>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"You must wait before using a command");
SetPVarInt(playerid,"CMDABUSE",GetTickCount()+5000);
// REST OF CODE
return 1;
}

For ZCMD
pawn Code:
CMD:.....
{
if(GetPVarInt(playerid,"CMDABUSE")>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"You must wait before using a command");
SetPVarInt(playerid,"CMDABUSE",GetTickCount()+5000);
// REST OF CODE
return 1;
}
Torran is offline   Reply With Quote
Old 04/04/2010, 06:48 PM   #2
BlackAgent007
Little Clucker
 
Join Date: Mar 2010
Posts: 12
Reputation: 0
Default Re: [TUT] How to stop command abusing

nice tut thanks mate.. ill try it as soon as possible
BlackAgent007 is offline   Reply With Quote
Old 04/04/2010, 08:10 PM   #3
biltong
Gangsta
 
Join Date: Jan 2010
Posts: 551
Reputation: 0
Default Re: [TUT] How to stop command abusing

I thought public functions have to return something.
__________________
My releases:
[FS]Admin Click - An admin shortcut script. Lots of commands like kick and ban in a few mouse clicks!
[FS]Vehicle Names - Simple script that displays your vehicle's name whenever you enter one.
[GM]Cops 'n Criminals - An unusual TDM.


Not active anymore, PM me if necessary.
biltong is offline   Reply With Quote
Old 04/04/2010, 08:11 PM   #4
Torran
High-roller
 
Join Date: Jan 2010
Posts: 1,794
Reputation: 1
Default Re: [TUT] How to stop command abusing

Quote:
Originally Posted by biltong
I thought public functions have to return something.
I never return on publics for my timers
Torran is offline   Reply With Quote
Old 04/04/2010, 08:50 PM   #5
Torran
High-roller
 
Join Date: Jan 2010
Posts: 1,794
Reputation: 1
Default Re: [TUT] How to stop command abusing

Edited first post,
With a much simpler code,
And simpler way of doing it,
Thanks to Joe_Staff,
Torran is offline   Reply With Quote
Old 06/04/2010, 03:18 PM   #6
[MWR]Blood
High-roller
 
Join Date: Apr 2009
Posts: 2,406
Reputation: 105
Default Re: [TUT] How to stop command abusing

Nice Tut!Very useful
[MWR]Blood is offline   Reply With Quote
Old 06/04/2010, 03:37 PM   #7
Rac3r
Gangsta
 
Join Date: May 2007
Posts: 700
Reputation: 32
Default Re: [TUT] How to stop command abusing

Quote:
Originally Posted by biltong
I thought public functions have to return something.
No.

Bit of help for you:
pawn Code:
if( IsPlayerSomething(playerid) )SetPlayerHealth(playerid, 100.0);
This, needs a return. 1 for true, 0 for false.
pawn Code:
IsPlayerSomething(playerid)
{
    if(GetPlayerTeam(playerid) == 2) return 1;
    else return 0
}
Another thing to be aware of is if you return something from a function, at the end it must also return something.
pawn Code:
public MyTimer()
{
    new x;
    x = random(2);
    if(x == 1)return 1;
    //code
    //code
    //code
    //code
    return 1;//you have to return  
}
Most functions though don't need a return for it to finish.
pawn Code:
SetTimer("MyTimer",1000,1);
pawn Code:
public MyTimer()
{
}
pawn Code:
MakePlayerDoSomething(playerid);
pawn Code:
MakePlayerDoSomething(playerid)
{
}
Rac3r is offline   Reply With Quote
Old 06/04/2010, 03:55 PM   #8
biltong
Gangsta
 
Join Date: Jan 2010
Posts: 551
Reputation: 0
Default Re: [TUT] How to stop command abusing

I get warnings telling me that public function x should return a value, that's why I thought public functions always return something.
__________________
My releases:
[FS]Admin Click - An admin shortcut script. Lots of commands like kick and ban in a few mouse clicks!
[FS]Vehicle Names - Simple script that displays your vehicle's name whenever you enter one.
[GM]Cops 'n Criminals - An unusual TDM.


Not active anymore, PM me if necessary.
biltong is offline   Reply With Quote
Old 06/04/2010, 04:45 PM   #9
Rac3r
Gangsta
 
Join Date: May 2007
Posts: 700
Reputation: 32
Default Re: [TUT] How to stop command abusing

There is probably a return higher up in the function. (Like below)

pawn Code:
public MyTimer()
{
    new x;
    x = random(2);
    if(x == 1)return 1;// you have a return here, but you don't have one at the end
    //code
    //code
    //code
    //code
}
Rac3r is offline   Reply With Quote
Old 12/04/2010, 12:42 PM   #10
johnathon956
Big Clucker
 
Join Date: Jan 2010
Posts: 151
Reputation: 0
Default Re: [TUT] How to stop command abusing

i edited the carmenu by Garsino. so people couldnt abuse it by over spawning cars
lol i even made it so they cant spawn huge planes XD
johnathon956 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Car Lock abusing ArTisT Help Archive 4 12/05/2010 04:15 PM
Server Commands stop working, when typed a command DaHP14Y3R Help Archive 2 08/04/2010 06:17 PM
How to do , when I typing command, The bot is stop? _Ben_[Fux-c.co.il RP] Help Archive 3 08/09/2009 10:54 AM
I think im abusing VARS Paladin Help Archive 9 02/08/2009 07:18 PM
Please, can we stop this? Kirkmaster10 General 6 15/06/2009 07:39 PM


All times are GMT. The time now is 08:34 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.