Raised This Month: $ Target: $400
 0% 

how to make a plugin run once for a client which connects to the server.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pcharsi
Junior Member
Join Date: Dec 2011
Old 12-27-2011 , 12:10   how to make a plugin run once for a client which connects to the server.
Reply With Quote #1

i m new to script writing i need a code(string) which make a plugin run only once when a player connects to server and then it should stop for that player either it worked or not it should stop runing as to stop
SZ_GetSpace: overflow on netchan->message
WARNING: reliable overflow for MS
plz help need urgent attention
pcharsi is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-27-2011 , 14:26   Re: how to make a plugin run once for a client which connects to the server.
Reply With Quote #2

Explain exactly what you are trying to do.
__________________
fysiks is offline
Ex1ne
Senior Member
Join Date: Oct 2011
Location: Norway
Old 12-28-2011 , 22:35   Re: how to make a plugin run once for a client which connects to the server.
Reply With Quote #3

I think i know what you mean, i made this a while back. It could give an idea of how to do it.

PHP Code:
#include <amxmisc>
#include <hamsandwich>
#include <fun>
#include <cstrike>
new bool:GiftUsed[33]
public 
plugin_init() {
    
register_plugin("Welcome Gift""0.3""Ex1ne")
    
RegisterHam(Ham_Spawn"player""Spawn"1
}
public 
Spawn(id) {
    if(
GiftUsed[id] == true) {
        return 
PLUGIN_HANDLED 
    
}
    
give_item(id"weapon_deagle")
    
cs_set_user_bpammo(idCSW_DEAGLE35)
    
GiftUsed[id] = true
    
return PLUGIN_HANDLED

__________________
Ex1ne is offline
pcharsi
Junior Member
Join Date: Dec 2011
Old 01-02-2012 , 10:40   Re: how to make a plugin run once for a client which connects to the server.
Reply With Quote #4

Quote:
Originally Posted by Ex1ne View Post
I think i know what you mean, i made this a while back. It could give an idea of how to do it.

PHP Code:
#include <amxmisc>
#include <hamsandwich>
#include <fun>
#include <cstrike>
new bool:GiftUsed[33]
public 
plugin_init() {
    
register_plugin("Welcome Gift""0.3""Ex1ne")
    
RegisterHam(Ham_Spawn"player""Spawn"1
}
public 
Spawn(id) {
    if(
GiftUsed[id] == true) {
        return 
PLUGIN_HANDLED 
    
}
    
give_item(id"weapon_deagle")
    
cs_set_user_bpammo(idCSW_DEAGLE35)
    
GiftUsed[id] = true
    
return PLUGIN_HANDLED

ex1ne thanx man i got the idea of your to use if statement and its what i been looking for great thanx and sorry to reply late as i was sort busy these days thanx once again have a great year happy new year.
pcharsi is offline
Erox902
Veteran Member
Join Date: Jun 2009
Location: Never Never Land
Old 01-02-2012 , 12:28   Re: how to make a plugin run once for a client which connects to the server.
Reply With Quote #5

PHP Code:
if(GiftUsed[id] == true) { 
        return 
PLUGIN_HANDLED 
--->
PHP Code:
if(GiftUsed[id] || !is_user_alive(id)) { 
        return 
PLUGIN_HANDLED 
If you're using bools you don't need to check with == ( if you don't absolutely prefer it that way ofc ),
Just "if ( bool )" for true or "if ( !bool )" for false.
( Also works for variables if you wanna check if it is zeroed, "!" )

And in the spawn function there should always be an alive check,
the spawn function gets called once on connect aswell, so in this case...
the bool will be true before he spawns for the first time.
Erox902 is offline
Ex1ne
Senior Member
Join Date: Oct 2011
Location: Norway
Old 01-05-2012 , 06:08   Re: how to make a plugin run once for a client which connects to the server.
Reply With Quote #6

Quote:
Originally Posted by Erox902 View Post
PHP Code:
if(GiftUsed[id] == true) { 
        return 
PLUGIN_HANDLED 
--->
PHP Code:
if(GiftUsed[id] || !is_user_alive(id)) { 
        return 
PLUGIN_HANDLED 
*facepalm*
PHP Code:
    RegisterHam(Ham_Spawn"player""Spawn"1
It triggers by spawning, why check if he's alive? *facepalm again*
__________________
Ex1ne is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 01-05-2012 , 06:45   Re: how to make a plugin run once for a client which connects to the server.
Reply With Quote #7

He explained why. Read the whole post.
Quote:
Originally Posted by Ex1ne View Post
*facepalm*
__________________
Impossible is Nothing
Sylwester is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 12:09.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode