AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how to make a plugin run once for a client which connects to the server. (https://forums.alliedmods.net/showthread.php?t=174925)

pcharsi 12-27-2011 12:10

how to make a plugin run once for a client which connects to the server.
 
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

fysiks 12-27-2011 14:26

Re: how to make a plugin run once for a client which connects to the server.
 
Explain exactly what you are trying to do.

Ex1ne 12-28-2011 22:35

Re: how to make a plugin run once for a client which connects to the server.
 
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



pcharsi 01-02-2012 10:40

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

Originally Posted by Ex1ne (Post 1621396)
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.

Erox902 01-02-2012 12:28

Re: how to make a plugin run once for a client which connects to the server.
 
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.

Ex1ne 01-05-2012 06:08

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

Originally Posted by Erox902 (Post 1623784)
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*

Sylwester 01-05-2012 06:45

Re: how to make a plugin run once for a client which connects to the server.
 
He explained why. Read the whole post.
Quote:

Originally Posted by Ex1ne (Post 1625809)
*facepalm*



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

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