How do African people deal with elephants being a hazard?

The people affected have tried to use repellents such as pepper to ward of elephants. Otherwise, the people may attack the elephant or scare it off with spears and whatever other weapons they have to use.